Div
<Div /> is equivalent to <div />.
// Creating a divimport { Div } from "atomize";<Divbg="gray200"d="flex"align="center"p="1rem">This is the div</Div>
Text
<Text /> is by default equal to <p>. To change that tag tag props can be passed to the component.
This is h1 of display1 size
// Creating a h1import { Text } from "atomize";<Text tag="h1" textSize="display1" m={{ b: "4rem" }}>This is h1 of display1 size</Text>
Icons
<Icon /> can be used to display any of the below icons. Icon accepts the props of name, color & size in adition to the available utility props.
// Add Iconimport { Icon } from "atomize";<Icon name="Add" color="black" size="20px" />
Input & Textarea
Any of the utility property can also be passed to Input. Input by default is of height h="2.5rem", padding p: { x: "0.75rem" }, and uses flex to align items center.
// Basic Inputimport { Input } from "atomize";const BasicInput = () => {return (<Input placeholder="Basic Input" />);}
Checkbox
To make the area clickable for <Checkbox /> changes, the area is wrapped inside<Label />.
You should manage the checked states with react states.
You can also change the size, inactiveColor & activeColor of the Checkbox.
isLoading can be passed if the value of checkbox is loading.
// Basic Checkboxesimport { Checkbox, Label } from "atomize";const BasicCheckboxes = () => {return (<><Label align="center" textWeight="600" m={{ b: "0.5rem" }}><Checkbox /> Normal Checkbox</Label><Label align="center" textWeight="600" m={{ b: "0.5rem" }}><Checkbox disabled /> Disabled</Label><Label align="center" textWeight="600" m={{ b: "0.5rem" }}><Checkbox undetermine /> Undetermine</Label></>);}
Radiobox
To make the area clickable for <Radiobox /> changes, the area is wrapped inside<Label />.
Manage radios with react States.
You can also change the size, inactiveColor & activeColor of the Radiobox.
isLoading can be passed if the value of Radiobox is loading.
// Managing through Stateimport { Radiobox, Label, Div } from "atomize";class ManagingRadioboxWithState extends React.Component {constructor(props) {super(props);this.state = {selectedCountValue: 1};this.toggleSelectedCount = this.toggleSelectedCount.bind(this);}toggleSelectedCount(value) {this.setState({selectedCountValue: value,})}render() {const { selectedCountValue} = this.state;return (<Div d="flex"><Labelalign="center"textWeight="600"m={{ b: "0.5rem", r: "2rem" }}><RadioboxonChange={() => this.toggleSelectedCount(1)}checked={ selectedCountValue === 1 }name="count"/>1</Label><Labelalign="center"textWeight="600"m={{ b: "0.5rem", r: "2rem" }}><RadioboxonChange={() => this.toggleSelectedCount(2)}checked={ selectedCountValue === 2 }name="count"/>2</Label><Labelalign="center"textWeight="600"m={{ b: "0.5rem", r: "2rem" }}><RadioboxonChange={() => this.toggleSelectedCount(3)}checked={ selectedCountValue === 3 }name="count"/>3</Label><Label align="center" textWeight="600" m={{ b: "0.5rem" }}><RadioboxonChange={() => this.toggleSelectedCount(4)}checked={ selectedCountValue === 4 }name="count"/>4</Label></Div>);}}
Switch
Switch works exactly like checkbox, except it can only be managed through state.
You can style the active and inactive state of switch by using activeColor, inactiveColor, activeShadow & inactiveShadow.
isLoading can be passed for the loading state of the switch.
// Basic Switchesimport { Switch, Label } from "atomize";class Switches extends React.Component {constructor(props) {super(props);this.state = {selectedSwitchValue1: false,selectedSwitchValue2: false};}render() {const { selectedSwitchValue1, selectedSwitchValue2 } = this.state;return (<LabelonClick={() =>this.setState({ selectedSwitchValue1: !selectedSwitchValue1 })}align="center"textWeight="600"m={{ b: "1rem" }}><Switchchecked={selectedSwitchValue1}/>Normal Switch</Label>);}}
Image
You can use <Image src="image/url" /> for rendering an image component, or if you want to maintain a constant ratio you can use it in background like<Div bgImg="image/url" bgSize="cover" />
// Imagesimport { Image, Div, Row, Col } from "atomize";const BasicImages = () => {return (<Row><Col><Image src="https://images.unsplash.com/photo-1559963629-38ed0fbd4c86?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1000&q=80" /></Col><Col><DivbgImg="https://images.unsplash.com/photo-1559963629-38ed0fbd4c86?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1000&q=80"bgSize="cover"bgPos="center"h="20rem"/></Col></Row>);}
Tags
Tag for categorizing or markup.
You can pass any utility props to define how the Tag should look like. Below are bordered custom tags.
You can also change the padding, border radius and textSize of the Tags as shown below.
// Basic Tagsimport { Div, Tag, Anchor, Icon } from "atomize";const BasicTags = () => {return (<Div d="flex"><Tag m={{ r: "1rem", b: "1rem" }}>Tag 1</Tag><Tag m={{ r: "1rem", b: "1rem" }}>Link</Tag><Tagm={{ r: "1rem", b: "1rem" }}suffix={<Iconname="Cross"size="12px"m={{ l: "1rem" }}cursor="pointer"/>}>Close</Tag><Tagm={{ r: "1rem", b: "1rem" }}prefix={<Icon name="Edit" size="12px" m={{ r: "0.25rem" }} />}>Edit</Tag><Anchor href="https://www.google.com" target="_blank"><TaghoverBg="info200"m={{ r: "1rem", b: "1rem" }}prefix={<Icon name="Link" size="12px" m={{ r: "0.25rem" }} />}cursor="pointer">Link</Tag></Anchor></Div>);}
Anchor
<Anchor/> is equilant to <a/> and can be passed most of the utilities as props. Underline is removed by default. You can pass textDecor="underline" to get that underlined link.
You can also wrap any div, tag or button inside an anchor.
// Basic Linksimport { Div, Tag, Anchor, Icon } from "atomize";const BasicLinks = () => {return (<><Anchorhref="https://www.google.com"target="_blank"d="block"m={{ b: "1rem" }}>This is the link</Anchor><Anchorhref="https://www.google.com"target="_blank"textDecor="underline"d="block">This is the underlined link</Anchor></>);}
Collapse
<Collapse /> can be used when you need to show/hide some element. isOpen props define the state of the component.
// Basic Linksimport { Div, Tag, Anchor, Icon } from "atomize";class Collapse extends React.Component {constructor(props) {super(props);this.state = {showCollapse: false};}render() {const { selectedCode, showCollapse } = this.state;return (<><ButtononClick={() => this.setState({ showCollapse: !showCollapse })}m={{ b: "1rem" }}>Toggle Collapse</Button><Collapse isOpen={showCollapse}><Divbg="gray100"border="1px solid"borderColor="gray400"rounded="lg">{["This", "section", "is", "inside", "collapse"].map((name, index) => (<Divp={{ x: "1rem", y: "0.75rem" }}border={{ b: index !== 4 && "1px solid" }}borderColor="gray400">{name}</Div>))}</Div></Collapse></>);}}