1.0.3 • Published 5 months ago

react-battery-level v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

React Battery Level

Simple customizable battery component!

목차

Features

Installation

npm i react-battery-level

Usage

import BatteryLevel from 'react-battery-level';

function App() {
  return (
    <BatteryLevel
      width="250"
      gauge={75}
      isCharging
      borderStyles={{
        color: '#000',
      }}
    />
  );
}

export default App;

Props

BatteryLevel 컴포넌트는 다음과 같은 props를 받습니다:

PropTypeDefaultDescription
widthnumber | string"150"Optional. The width of the battery icon.
heightnumber | string"100%"Optional. The height of the battery icon.
gaugenumberNoneRequired. The charge level of the battery (0-100).
gaugeColorstring"#34C759"Optional. The color of the battery fill.
isChargingbooleanfalseOptional. Indicates if the battery is charging.
showPercentagebooleanfalseOptional. Shows the battery percentage inside the SVG.
borderStylesobject{}Optional. Styling for the border.
lightningStylesobject{}Optional. Styling for the lightning bolt.
percentageStylesobject{}Optional. Styling for the battery percentage text.

borderStyles Object

KeyTypeDefaultDescription
colorstring"black"Stroke color for the battery border.
strokeWidthnumber1Stroke width for the battery border.
radiusnumber5Border radius for the battery.

lightningStyles Object

KeyTypeDefaultDescription
fillstring"yellow"Fill color for the lightning bolt.
strokestringnoneStroke color for the lightning bolt.
strokeWidthnumber0.5Stroke width for the lightning bolt.
positionobject{ x: 15, y: -1 }Position of the lightning bolt.
transformobject{ scale: 1, rotate: 10 }Transform properties for the lightning bolt.

percentageStyles Object

KeyTypeDefaultDescription
fontSizenumber8Font size for the battery percentage text.
colorstring"black"Color for the battery percentage text.

License

MIT