👋
🤔
🤔
🤔
🤔
🤔
🤔
🙃
🙃
👋
Tip # 1
Tip # 1
<Button primary>
Buy more stuff
</Button>Tip # 1
<Button secondary>
Buy more stuff
</Button>Tip # 1
<Button cta>
Buy more stuff
</Button>Tip # 1
<Button
cta
primary
secondary
>
Buy more stuff
</Button>Tip # 1
<Button
variant="cta"
>
Buy more stuff
</Button>Tip # 1
<Button
variant="cta"
loading
disabled
>
Buying more stuff
</Button>Tip # 2
Tip # 2
<Modal />Tip # 2
<Modal
showCloseButton
isOpen
title="My modal"
content="Here is some modal content"
onLeftButtonClick={handleLeftButtonClick}
onRightButtonClick={handleRightButtonClick}
leftButtonLabel="Cancel"
rightButtonLabel="Ok"
rightButtonVariant="secondary"
overlayColor="rgba(0,0,255,1)"
background="white"
/>Tip # 2
<ModalOverlay>
Are you sure you want a modal?
</ModalOverlay>Tip # 2
<ModalOverlay>
<ModalBox>
Are you sure you want a modal?
</ModalBox>
</ModalOverlay>Tip # 2
<ModalOverlay>
<ModalBox>
<ModalCloseButton />
Are you sure you want a modal?
</ModalBox>
</ModalOverlay>Tip # 2
<ModalOverlay>
<ModalBox>
<ModalCloseButton />
<ModalTitle>Modals!</ModalTitle>
Are you sure you want a modal?
</ModalBox>
</ModalOverlay>Tip # 2
<ModalOverlay>
<ModalBox>
<ModalCloseButton />
<ModalTitle>Modals!</ModalTitle>
<ModalContent>
Are you sure you want a modal?
</ModalContent>
</ModalBox>
</ModalOverlay>Tip # 2
<ModalOverlay>
<ModalBox>
<ModalCloseButton />
<ModalTitle>Modals!</ModalTitle>
<ModalContent>
Are you sure you want a modal?
</ModalContent>
<ModalFooter>
<button>
Nah
</button>
</ModalFooter>
</ModalBox>
</ModalOverlay>Tip # 2
<ModalOverlay>
<ModalBox>
<ModalCloseButton />
<ModalTitle>Modals!</ModalTitle>
<ModalContent>
Are you sure you want a modal?
</ModalContent>
<ModalFooter>
<button>
Nah
</button>
</ModalFooter>
</ModalBox>
</ModalOverlay>Tip # 2
<ModalOverlay>
<ModalBox>
<ModalContent>
Are you sure you want a modal?
</ModalContent>
<ModalFooter>
<button>
Nah
</button>
</ModalFooter>
</ModalBox>
</ModalOverlay>Tip # 2
const Modal = (props) => (
<ModalOverlay>
<ModalBox>
<ModalCloseButton />
<ModalTitle>{props.title}</ModalTitle>
<ModalContent>
{props.children}
</ModalContent>
<ModalFooter>
{props.buttons}
</ModalFooter>
</ModalBox>
</ModalOverlay>
);Tip # 2
<Modal title="Modals are cool">
And composition is the best!
</Modal>Tip # 3
Tip # 3
<Card>
<CardImage src="/phone.png" alt="My phone" />
<CardContent>
My new phone
</CardContent>
</Card>Tip # 3
<Card as="li">
<CardImage src="/phone.png" alt="My phone" />
<CardContent>
My new phone
</CardContent>
</Card>Tip # 3
<Card as={Link} to="/phone">
<CardImage src="/phone.png" alt="My phone" />
<CardContent>
My new phone
</CardContent>
</Card>Tip # 3
function Card(props) {
return (
<div className="card">
{props.children}
</div>
);
}Tip # 3
function Card(props) {
const Element = props.as ?? 'div';
return (
<Element className="card">
{props.children}
</Element>
);
}Tip # 3
function Card({ children, as: Element = 'div' }) {
return (
<Element className="card">
{props.children}
</Element>
);
}Tip # 3
<Card as="li" />
<Button as="a" />
<GridRow as="section" />
<Box as="footer" />
Tip # 4
Tip # 4
function Card({
children,
as: Element = 'div',
}) {
return (
<Element className="card">
{props.children}
</Element>
);
}Tip # 4
function Card({
children,
as: Element = 'div',
...rest
}) {
return (
<Element className="card">
{props.children}
</Element>
);
}Tip # 4
function Card({
children,
as: Element = 'div',
...rest
}) {
return (
<Element className="card" {...rest}>
{props.children}
</Element>
);
}Tip # 4
function Card({
children,
className = '',
as: Element = 'div',
...rest
}) {
return (
<Element
className={`card ${className}`}
{...rest}
>
{props.children}
</Element>
);
}Tip # 4
<Card
as={Link}
to="/phone"
className="extra-classy"
>
<CardImage src="/phone.png" alt="My phone" />
<CardContent>
My phone
</CardContent>
</Card>Tip # 4
Tip # 5
Tip # 5
<Button />Tip # 5
<Button type="primary" />Tip # 5
<Button type="primary" buttonType="button" />Tip # 5
<Button type="button" variant="primary" />Tip # 5
<Button
type="button"
variant="primary"
/>Tip # 5
<Button
type="button"
variant="primary"
isLoading
/>Tip # 5
<Button
type="button"
variant="primary"
ariaBusy
/>Tip # 5
<Button
type="button"
variant="primary"
aria-busy
/>Tip # 5
<Button
type="button"
variant="primary"
aria-busy
aria-label="Please wait"
/>⬅ Your docs
Tip # 1
Tip # 1
Tip # 1
/** Card
*
* Used for creating elements that pop out from the page
* Can also be used as clickable elements, with or without
* images, titles and text content.
*
* If you need more control, please look at the composable
* components instead - CardBox, CardContent, CardTitle and CardImage
*/
function Card({
children,
className = '',
as: Element = 'div',
...rest
}) {
return ...;
}Tip # 1
/** Card
*
* Used for creating elements that pop out from the page
* Can also be used as clickable elements, with or without
* images, titles and text content.
*
* If you need more control, please look at the composable
* components instead - CardBox, CardContent, CardTitle and CardImage
*
* @example
* <Card as="a" href="/example">
* Go to example
* </Card>
*/
function Card({
children,
className = '',
as: Element = 'div',
...rest
}) {
return ...;
}Tip # 1
/** Card
*
* ...
*/
function Card({
/** The content inside the card. Could be just text, or a CardImage component */
children,
/** Extra class names are added to the root node */
className = '',
/** The type of the root element. Defaults to div. */
as: Element = 'div',
...rest
}) {
return ...;
}Tip # 1
Tip # 3
Tip # 3
Tip # 1
Tip # 1
Tip # 1
// eslintrc.json
{
"extends": "react-app"
}Tip # 2
Tip # 2
type ButtonProps = {
as?: string | React.ComponentType;
variant: 'primary' | 'secondary' | 'cta';
onClick: () => void;
children: React.ReactNode;
}
const Button: React.FC<ButtonProps> = (props) => {
return (...);
}Tip # 2
Tip # 3
Tip # 3
Tip # 4