25
loading...
This website collects cookies to deliver better user experience
<button onclick="alert('hello world');">Hello</button>
Chakra UI is a simple, modular and accessible component library that gives you the building blocks you need to build your React applications.
.jsx
or .tsx
files and we would create another file with css and reference them in our component file.components
- mycomponent.jsx
- mycomponent.css
backgroundColor
instead of background-color
and pseudo selectors as well. We are passing styles as a object to a custom prop css
which is inferred by emotion and applies those styles inline to that div
.If you want to have a deep dive on this concept, please read thorough the documentation from emotion
import { Box } from "@chakra-ui/react";
return (
<Box
backgroundColor="hotpink"
_hover={{
color: "lightgreen"
}}
>
This has a hotpink background.
</Box>
);
<Box/>
as props. The Box component renders a div
by default. return (
<Box
css={{
backgroundColor: "hotpink",
"&:hover": {
color: "lightgreen"
}
}}
>
This has a hotpink background.
</Box>
);
Grid
and Flex
to handle layouts exclusively like the one seen above. <chakra.form/>
which simply renders HTML <form>
but the beauty is, it can accept chakra's style props. We can convert any custom component to receive chakra props with the chakra
function. styled
function from emotion.import styled from '@emotion/styled'
const Button = styled.button`
color: turquoise;
`
render(<Button>This my button component.</Button>)
Esc
closes the Modal.document.body
to
break it out of the source order and make it easy to add aria-hidden
to its
siblings.<VisuallyHidden/>
which is not visible to the normal user but would be accessible by screen readers. This is useful for providing additional details to a icon button or image which cannot be perceived by visually My website is built with Chakra UI components and I feel very happy about it 🥳