### Install Atomize React and Dependencies
Source: https://atomizecode.com/docs/react/intro/setup
This command installs the Atomize UI library and `react-transition-group` as a dependency using Yarn. These packages are essential for building user interfaces with Atomize.
```bash
yarn add atomize react-transition-group
```
--------------------------------
### Customize Atomize Theme with ThemeProvider
Source: https://atomizecode.com/docs/react/intro/setup
This example shows how to apply a custom theme to your Atomize components using the `ThemeProvider`. You can define custom colors, fonts, and other design tokens within the `theme` object, allowing for extensive customization of the UI library's appearance.
```javascript
import React from 'react';
import { ThemeProvider, StyleReset } from 'atomize';
import App from './src/App';
const theme = {
colors: {
primary: 'tomato',
accent: 'yellow'
}
};
export default function Main() {
return (
);
}
```
--------------------------------
### Integrate StyleReset in React Root Component
Source: https://atomizecode.com/docs/react/intro/setup
This example demonstrates how to include the `StyleReset` component from Atomize in your main React application component (e.g., `index.js` or `App.js`) to apply global style resets. It's crucial for ensuring consistent styling across your application and should be placed at the root of your component tree.
```javascript
import React from 'react';
import { StyleReset } from 'atomize';
import App from './src/App';
export default function Main() {
return (
<>
>
);
}
```
--------------------------------
### Basic Input Component Usage in Atomize React
Source: https://atomizecode.com/docs/react/intro/atoms
Illustrates the basic implementation of the Input component from Atomize React. This example shows how to import the component and render a simple input field with a placeholder text.
```jsx
import { Input } from "atomize";
const BasicInput = () => {
return (
);
}
```
--------------------------------
### React Row and Col Basic Grid Structure Example
Source: https://atomizecode.com/docs/react/intro/grid
Illustrates the fundamental use of AtomizeCode's `Row` and `Col` components to create a responsive grid layout. This example demonstrates how to divide content into columns using flexbox-based sizing, showcasing a 5-of-12 and 7-of-12 column division.
```JavaScript
// Basic Column Structure
import { Row, Col, Div } from "atomize";
ReactDOM.render(
This is 5 of 12
This is 7 of 12
, mountNode
);
```
--------------------------------
### Examples of Applying Responsive Props in Atomize React
Source: https://atomizecode.com/docs/react/intro/responsive
These examples demonstrate how to utilize the responsive prop system in Atomize React components. By passing an object with breakpoint keys (e.g., xs, md, lg) to styling props like p (padding) or border, developers can easily define responsive styles that adapt to different screen sizes.
```JavaScript
// Padding
p={{ xs: '1rem', md: '4rem' }}
// Padding Top
p={{ t: {xs: '1rem', md: '4rem' }}}
// border
border={{ xs: '1px solid', lg: '2px dashed' }}
// Border Top & Bottom
border={
t: { xs: '1px solid', lg: '2px dashed' }
b: { xs: '1px solid', lg: '2px dashed' }
}
```
--------------------------------
### React Container Component Usage Example
Source: https://atomizecode.com/docs/react/intro/grid
Demonstrates the basic usage of the AtomizeCode `Container` component in a React application. This component serves as the fundamental element for the grid system, automatically adjusting its max-width based on theme breakpoints for responsive design.
```JavaScript
// Container
import { Div, Container } from "atomize";
ReactDOM.render(
{/* your Content goes here */}
, mountNode
);
```
--------------------------------
### Add Custom Shadows to Atomize React Theme
Source: https://atomizecode.com/docs/react/intro/theme
This example illustrates how to extend the default shadow values in Atomize React by adding a custom shadow definition to the theme object. The new shadow can then be applied to components using the `shadow` prop.
```javascript
import {
ThemeProvider,
Div,
Row,
Col } from "atomize";
const theme = {
shadows: {
"new-shadow": "0 16px 24px -2px rgba(0, 0, 0, 0.08)"
}
};
ReactDOM.render(
New Shadow
, mountNode
);
```
--------------------------------
### Creating Basic Links with Atomize Anchor Component
Source: https://atomizecode.com/docs/react/intro/atoms
This code snippet demonstrates how to create basic hyperlinks using the `Anchor` component from the Atomize UI library. It showcases two examples: a standard link and an underlined link, both configured to open in a new browser tab.
```javascript
import { Div, Tag, Anchor, Icon } from "atomize";
const BasicLinks = () => {
return (
<>
This is the link
This is the underlined link
>
);
}
```
--------------------------------
### Customize Component Transitions in Atomize React
Source: https://atomizecode.com/docs/react/intro/theme
This example demonstrates how to define and apply custom transition properties within the Atomize React theme. It shows a `Div` component animating its `transform` property using a custom 'custom' transition defined in the theme, triggered by a state change.
```javascript
import { Div, Text, Tag, Row, Col, ThemeProvider } from "atomize";
const theme = {
transition: {
custom: "transform 0.8s linear"
}
};
class Transition extends React.Component {
constructor(props) {
super(props);
this.state = {
animate: false
};
this.toggleState = this.toggleState.bind(this);
}
componentDidMount() {
setInterval(this.toggleState, 1000);
}
toggleState() {
const { animate } = this.state;
this.setState({ animate: !animate });
}
render() {
const { animate } = this.state;
return(
);
}
}
ReactDOM.render(, mountNode);
```
--------------------------------
### Basic SideDrawer Implementation in Atomize React
Source: https://atomizecode.com/docs/react/intro/molecules
This snippet illustrates how to implement a basic side drawer (or sidebar) component using Atomize React. It covers the essential `isOpen` and `onClose` props for controlling visibility and includes example content with an icon, text, and action buttons. The component demonstrates how to integrate a side drawer into a React application.
```React
import { Div, Button, SideDrawer, Icon, Text } from "atomize";
const BasicSideDrawer = ({ isOpen, onClose }) => {
return (
This is the modal
);
};
class Drawer extends React.Component {
constructor(props) {
super(props);
this.state = {
showSideDrawer: false
};
}
render() {
const { showSideDrawer } = this.state;
return (
<>
this.setState({ showSideDrawer: false })}
/>
>
);
}
}
export default Drawer;
```
--------------------------------
### Overwrite Atomize React Default Colors
Source: https://atomizecode.com/docs/react/intro/theme
This example demonstrates how to override the default color palette in Atomize React by defining new values for existing color names within the `ThemeProvider`. It shows how to create a custom brand color scale from 100 to 900.
```JavaScript
import { ThemeProvider, Div, Text } from "atomize";
const theme = {
colors: {
brand100: "#F9F8FC",
brand200: "#F3F1FA",
brand300: "#E9E6F6",
brand400: "#D2CCEC",
brand500: "#BCB3E2",
brand600: "#9C8FD6",
brand700: "#6F5CC3",
brand800: "#553EB5",
brand900: "#382683",
}
};
const BrandColors = () => (
)
ReactDOM.render(, mountNode);
```
--------------------------------
### Atomize React Button Component Examples
Source: https://atomizecode.com/docs/react/intro/atoms
Demonstrates various styled Button components from Atomize React, including camera, message, and attachment buttons. Each button features custom background colors, hover effects, rounded corners, and embedded icons, showcasing common styling patterns.
```jsx
// Message Button
// Attachment Button
```
--------------------------------
### Basic Modal Implementation in Atomize React
Source: https://atomizecode.com/docs/react/intro/molecules
This snippet demonstrates how to create and manage a basic modal dialog using Atomize React components. It includes state management for modal visibility, custom content rendering with icons and text, and action buttons for user interaction. The modal is configured to align its content to the start.
```React
import { Div, Button, Modal, Icon, Text } from "atomize";
const AlignStartModal = ({ isOpen, onClose }) => {
return (
Do you really want to submit the request.
);
};
class BasicModal extends React.Component {
constructor(props) {
super(props);
this.state = {
showModal: false
};
}
render() {
const { showModal } = this.state;
return (
<>
this.setState({ showModal: false })}
/>
>
);
}
}
export default BasicModal;
```
--------------------------------
### Set Custom Font Sizes in Atomize React Theme
Source: https://atomizecode.com/docs/react/intro/theme
This example demonstrates how to define custom font sizes and their corresponding line heights within the Atomize React theme. The `textSize` property allows for granular control over typography, enabling the use of custom text sizes like 'customSize'.
```javascript
import { Text, ThemeProvider } from "atomize";
const theme = {
textSize: {
size: {
customSize: "25px"
},
height: {
customSize: "34px"
}
}
};
ReactDOM.render(
Custom Text Size
, mountNode
);
```
--------------------------------
### Basic Checkbox Component Usage in Atomize React
Source: https://atomizecode.com/docs/react/intro/atoms
Demonstrates the basic usage of the Checkbox component in Atomize React. Examples include a normal checkbox, a disabled checkbox, and an undetermined checkbox, all wrapped within a Label component for improved clickability.
```jsx
import { Checkbox, Label } from "atomize";
const BasicCheckboxes = () => {
return (
<>
>
);
}
```
--------------------------------
### Managing Radiobox State in Atomize React
Source: https://atomizecode.com/docs/react/intro/atoms
Demonstrates how to manage the checked state of Radiobox components in Atomize React using a React class component. It includes an example of toggling selected values and rendering multiple radioboxes within a flexible container.
```jsx
import { 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 (