Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
@chakra-ui/button
Advanced tools
Package description
@chakra-ui/button is a component from the Chakra UI library that provides a set of accessible, customizable, and composable button components for React applications. It allows developers to create buttons with various styles, sizes, and behaviors easily.
Basic Button
This code demonstrates how to create a basic button with a blue color scheme using the @chakra-ui/button package.
import { Button } from '@chakra-ui/react';
function App() {
return <Button colorScheme='blue'>Button</Button>;
}
Button Sizes
This code demonstrates how to create buttons of different sizes (small, medium, and large) using the @chakra-ui/button package.
import { Button } from '@chakra-ui/react';
function App() {
return (
<>
<Button size='sm'>Small</Button>
<Button size='md'>Medium</Button>
<Button size='lg'>Large</Button>
</>
);
}
Button Variants
This code demonstrates how to create buttons with different variants (solid, outline, and ghost) using the @chakra-ui/button package.
import { Button } from '@chakra-ui/react';
function App() {
return (
<>
<Button variant='solid'>Solid</Button>
<Button variant='outline'>Outline</Button>
<Button variant='ghost'>Ghost</Button>
</>
);
}
Button with Icon
This code demonstrates how to create a button with an icon using the @chakra-ui/button package.
import { Button } from '@chakra-ui/react';
import { FaArrowRight } from 'react-icons/fa';
function App() {
return <Button rightIcon={<FaArrowRight />} colorScheme='teal'>Button with Icon</Button>;
}
React-Bootstrap provides a set of React components that implement the Bootstrap framework. It offers a wide range of pre-styled components, including buttons, which can be customized using Bootstrap's utility classes. Compared to @chakra-ui/button, React-Bootstrap buttons are more tightly coupled with the Bootstrap design system.
Material-UI is a popular React component library that implements Google's Material Design. It provides a comprehensive set of components, including buttons, that are highly customizable and come with built-in accessibility. Material-UI buttons offer a different design aesthetic compared to @chakra-ui/button, focusing on Material Design principles.
Ant Design (antd) is a React UI library that provides a set of high-quality components, including buttons, following the Ant Design guidelines. It is widely used in enterprise applications and offers a rich set of features and customization options. Ant Design buttons have a distinct look and feel compared to @chakra-ui/button.
Readme
Buttons are used as triggers for actions. They are used in forms, toolbars, dialog footers and as stand-alone action triggers.
yarn add @chakra-ui/button
# or
npm i @chakra-ui/button
import { Button } from "@chakra-ui/button"
<Button colorScheme="green">Button</Button>
Use the size
prop to change the size of the button. You can set the value to
xs
, sm
, md
, or lg
.
<Stack>
<Button size="xs">Button</Button>
<Button size="sm">Button</Button>
<Button size="md">Button</Button>
<Button size="lg">Button</Button>
</Stack>
Use the variant
prop to change the visual style of the Button. You can set the
value to solid
, ghost
, outline
, or link
.
<ButtonGroup>
<Button variant="solid">Button</Button>
<Button variant="outline">Button</Button>
<Button variant="ghost">Button</Button>
<Button variant="link">Button</Button>
</ButtonGroup>
You can add left and right icons to the Button components.
<ButtonGroup>
<Button leftIcon={<EmailIcon />} variant="solid">
Email
</Button>
<Button rightIcon={<ArrowForwardIcon />} variant="outline">
Call us
</Button>
</ButtonGroup>
Pass isLoading
prop to the Button component to show its loading state. You can
optionally pass loadingText
prop.
You can also use a custom spinner to render your own spinner component.
<Stack>
<Button isLoading colorScheme="teal" variant="solid">
Email
</Button>
<Button
isLoading
colorScheme="teal"
variant="outline"
spinner={<BarSpinner />}
>
Submit
</Button>
</Stack>
FAQs
A React component that is a base button.
The npm package @chakra-ui/button receives a total of 520,195 weekly downloads. As such, @chakra-ui/button popularity was classified as popular.
We found that @chakra-ui/button demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.