Overview
- Getting Started
- Loading States
- Forms
- Feature Flags
- Portal
- Show
- For
- Text
- Toggle
- Local Storage
Actions
- Button
- Icon Button
Communication
- Admonition
- Accordion
- Avatar
- Notifications
- Progress Indicators
- Tag
- Tooltip
Containment
- Confirm Modal
- Prompt Modal
- CTA Modal
- Modaldeprecated
- Dialog
- Table
Navigation
- Menu
- Tabs
Selection
- Drag & Drop
- Checkbox
- Date Picker
- Radio
- Rating
- Select
- Combobox
- Switch
Inputs
- Field
- Input
- Textarea
- Labeldeprecated
- Fieldset
- Field Messagedeprecated
- File Uploader
Hooks & Helpers
- split-props
- trap-focusdeprecated
- use-root-colors
- use-theme
- use-theme-context
- use-toggledeprecated
Modal
Modals provide important prompts in a user flow.
1import {2 Modal,3 ModalHeader,4 ModalHeading,5 ModalDescription,6 trapFocus,7 useModal8} from '@cerberus/react'
Usage
Basic Usage
1import { Model } from '@cerberus/icons'2import {3 Modal,4 ModalHeader,5 ModalHeading,6 ModalDescription,7 Portal,8 useModal,9 trapFocus,10 Button,11} from '@cerberus/react'12import { hstack } from 'styled-system/patterns'13
14function OverviewPreview() {15 const { modalRef, show, close } = useModal()16 const handleKeyDown = trapFocus(modalRef)17
18 return (19 <div>20 <Button onClick={show}>Open Modal</Button>21
22 <Portal>23 <Modal onKeyDown={handleKeyDown} ref={modalRef}>24 <ModalHeader>25 <ModalHeading>This is a custom modal</ModalHeading>26 </ModalHeader>27 <ModalDescription>28 This is a custom modal that is can be whatever you need.29 </ModalDescription>30
31 <div32 className={hstack({33 color: 'info.text.100',34 mb: '10',35 })}36 >37 <Model size="5rem" />38 <Model size="5rem" />39 <Model size="5rem" />40 </div>41
42 <Button usage="outlined" onClick={close}>43 Close44 </Button>45 </Modal>46 </Portal>47 </div>48 )49}
Customization
You can customize each Modal component like you would any other component.
1import { Model } from '@cerberus/icons'2import {3 Modal,4 ModalHeader,5 ModalHeading,6 ModalDescription,7 Portal,8 useModal,9 trapFocus,10 Button,11} from '@cerberus/react'12import { css } from 'styled-system/css'13
14function CustomPreview() {15 const { modalRef, show, close } = useModal()16 const handleKeyDown = trapFocus(modalRef)17
18 return (19 <div>20 <Button21 className={css({22 bgColor: 'black',23 color: 'yellow',24 _hover: {25 bgColor: 'yellow',26 color: 'black',27 },28 })}29 onClick={show}30 >31 Enter the Wu32 </Button>33
34 <Portal>35 <Modal36 className={css({37 bgColor: 'black',38 })}39 onKeyDown={handleKeyDown}40 ref={modalRef}41 >42 <ModalHeader>43 <ModalHeading44 className={css({45 color: 'yellow !important',46 })}47 >48 Inspectah Deck49 </ModalHeading>50 <ModalDescription>51 Swingin' through your town like your neighborhood Spider-man!52 </ModalDescription>53 </ModalHeader>54
55 <Button56 className={css({57 borderColor: 'yellow',58 color: 'yellow',59 _hover: {60 borderColor: 'yellow',61 color: 'yellow',62 },63 })}64 usage="outlined"65 onClick={close}66 >67 Close68 </Button>69 </Modal>70 </Portal>71 </div>72 )73}
API
define function Modal(props: HTMLAttributes<HTMLDialogElement>): ReactNode
define function ModalHeader(props: HTMLAttributes<HTMLDivElement>): ReactNode
define function ModalHeading(props: HTMLAttributes<HTMLParagraphElement>): ReactNode
define function ModalDescription(props: HTMLAttributes<HTMLParagraphElement>): ReactNode
1import {2 Modal,3 ModalHeader,4 ModalHeading,5 ModalDescription,6 trapFocus,7 useModal8} from '@cerberus/react'
Usage
Basic Usage
1import { Model } from '@cerberus/icons'2import {3 Modal,4 ModalHeader,5 ModalHeading,6 ModalDescription,7 Portal,8 useModal,9 trapFocus,10 Button,11} from '@cerberus/react'12import { hstack } from 'styled-system/patterns'13
14function OverviewPreview() {15 const { modalRef, show, close } = useModal()16 const handleKeyDown = trapFocus(modalRef)17
18 return (19 <div>20 <Button onClick={show}>Open Modal</Button>21
22 <Portal>23 <Modal onKeyDown={handleKeyDown} ref={modalRef}>24 <ModalHeader>25 <ModalHeading>This is a custom modal</ModalHeading>26 </ModalHeader>27 <ModalDescription>28 This is a custom modal that is can be whatever you need.29 </ModalDescription>30
31 <div32 className={hstack({33 color: 'info.text.100',34 mb: '10',35 })}36 >37 <Model size="5rem" />38 <Model size="5rem" />39 <Model size="5rem" />40 </div>41
42 <Button usage="outlined" onClick={close}>43 Close44 </Button>45 </Modal>46 </Portal>47 </div>48 )49}
Customization
You can customize each Modal component like you would any other component.
1import { Model } from '@cerberus/icons'2import {3 Modal,4 ModalHeader,5 ModalHeading,6 ModalDescription,7 Portal,8 useModal,9 trapFocus,10 Button,11} from '@cerberus/react'12import { css } from 'styled-system/css'13
14function CustomPreview() {15 const { modalRef, show, close } = useModal()16 const handleKeyDown = trapFocus(modalRef)17
18 return (19 <div>20 <Button21 className={css({22 bgColor: 'black',23 color: 'yellow',24 _hover: {25 bgColor: 'yellow',26 color: 'black',27 },28 })}29 onClick={show}30 >31 Enter the Wu32 </Button>33
34 <Portal>35 <Modal36 className={css({37 bgColor: 'black',38 })}39 onKeyDown={handleKeyDown}40 ref={modalRef}41 >42 <ModalHeader>43 <ModalHeading44 className={css({45 color: 'yellow !important',46 })}47 >48 Inspectah Deck49 </ModalHeading>50 <ModalDescription>51 Swingin' through your town like your neighborhood Spider-man!52 </ModalDescription>53 </ModalHeader>54
55 <Button56 className={css({57 borderColor: 'yellow',58 color: 'yellow',59 _hover: {60 borderColor: 'yellow',61 color: 'yellow',62 },63 })}64 usage="outlined"65 onClick={close}66 >67 Close68 </Button>69 </Modal>70 </Portal>71 </div>72 )73}
API
define function Modal(props: HTMLAttributes<HTMLDialogElement>): ReactNode
define function ModalHeader(props: HTMLAttributes<HTMLDivElement>): ReactNode
define function ModalHeading(props: HTMLAttributes<HTMLParagraphElement>): ReactNode
define function ModalDescription(props: HTMLAttributes<HTMLParagraphElement>): ReactNode
1import {2 Modal,3 ModalHeader,4 ModalHeading,5 ModalDescription,6 trapFocus,7 useModal8} from '@cerberus/react'
Usage
Basic Usage
1import { Model } from '@cerberus/icons'2import {3 Modal,4 ModalHeader,5 ModalHeading,6 ModalDescription,7 Portal,8 useModal,9 trapFocus,10 Button,11} from '@cerberus/react'12import { hstack } from 'styled-system/patterns'13
14function OverviewPreview() {15 const { modalRef, show, close } = useModal()16 const handleKeyDown = trapFocus(modalRef)17
18 return (19 <div>20 <Button onClick={show}>Open Modal</Button>21
22 <Portal>23 <Modal onKeyDown={handleKeyDown} ref={modalRef}>24 <ModalHeader>25 <ModalHeading>This is a custom modal</ModalHeading>26 </ModalHeader>27 <ModalDescription>28 This is a custom modal that is can be whatever you need.29 </ModalDescription>30
31 <div32 className={hstack({33 color: 'info.text.100',34 mb: '10',35 })}36 >37 <Model size="5rem" />38 <Model size="5rem" />39 <Model size="5rem" />40 </div>41
42 <Button usage="outlined" onClick={close}>43 Close44 </Button>45 </Modal>46 </Portal>47 </div>48 )49}
Customization
You can customize each Modal component like you would any other component.
1import { Model } from '@cerberus/icons'2import {3 Modal,4 ModalHeader,5 ModalHeading,6 ModalDescription,7 Portal,8 useModal,9 trapFocus,10 Button,11} from '@cerberus/react'12import { css } from 'styled-system/css'13
14function CustomPreview() {15 const { modalRef, show, close } = useModal()16 const handleKeyDown = trapFocus(modalRef)17
18 return (19 <div>20 <Button21 className={css({22 bgColor: 'black',23 color: 'yellow',24 _hover: {25 bgColor: 'yellow',26 color: 'black',27 },28 })}29 onClick={show}30 >31 Enter the Wu32 </Button>33
34 <Portal>35 <Modal36 className={css({37 bgColor: 'black',38 })}39 onKeyDown={handleKeyDown}40 ref={modalRef}41 >42 <ModalHeader>43 <ModalHeading44 className={css({45 color: 'yellow !important',46 })}47 >48 Inspectah Deck49 </ModalHeading>50 <ModalDescription>51 Swingin' through your town like your neighborhood Spider-man!52 </ModalDescription>53 </ModalHeader>54
55 <Button56 className={css({57 borderColor: 'yellow',58 color: 'yellow',59 _hover: {60 borderColor: 'yellow',61 color: 'yellow',62 },63 })}64 usage="outlined"65 onClick={close}66 >67 Close68 </Button>69 </Modal>70 </Portal>71 </div>72 )73}
API
define function Modal(props: HTMLAttributes<HTMLDialogElement>): ReactNode
define function ModalHeader(props: HTMLAttributes<HTMLDivElement>): ReactNode
define function ModalHeading(props: HTMLAttributes<HTMLParagraphElement>): ReactNode
define function ModalDescription(props: HTMLAttributes<HTMLParagraphElement>): ReactNode
1import {2 Modal,3 ModalHeader,4 ModalHeading,5 ModalDescription,6 trapFocus,7 useModal8} from '@cerberus/react'
Usage
Basic Usage
1import { Model } from '@cerberus/icons'2import {3 Modal,4 ModalHeader,5 ModalHeading,6 ModalDescription,7 Portal,8 useModal,9 trapFocus,10 Button,11} from '@cerberus/react'12import { hstack } from 'styled-system/patterns'13
14function OverviewPreview() {15 const { modalRef, show, close } = useModal()16 const handleKeyDown = trapFocus(modalRef)17
18 return (19 <div>20 <Button onClick={show}>Open Modal</Button>21
22 <Portal>23 <Modal onKeyDown={handleKeyDown} ref={modalRef}>24 <ModalHeader>25 <ModalHeading>This is a custom modal</ModalHeading>26 </ModalHeader>27 <ModalDescription>28 This is a custom modal that is can be whatever you need.29 </ModalDescription>30
31 <div32 className={hstack({33 color: 'info.text.100',34 mb: '10',35 })}36 >37 <Model size="5rem" />38 <Model size="5rem" />39 <Model size="5rem" />40 </div>41
42 <Button usage="outlined" onClick={close}>43 Close44 </Button>45 </Modal>46 </Portal>47 </div>48 )49}
Customization
You can customize each Modal component like you would any other component.
1import { Model } from '@cerberus/icons'2import {3 Modal,4 ModalHeader,5 ModalHeading,6 ModalDescription,7 Portal,8 useModal,9 trapFocus,10 Button,11} from '@cerberus/react'12import { css } from 'styled-system/css'13
14function CustomPreview() {15 const { modalRef, show, close } = useModal()16 const handleKeyDown = trapFocus(modalRef)17
18 return (19 <div>20 <Button21 className={css({22 bgColor: 'black',23 color: 'yellow',24 _hover: {25 bgColor: 'yellow',26 color: 'black',27 },28 })}29 onClick={show}30 >31 Enter the Wu32 </Button>33
34 <Portal>35 <Modal36 className={css({37 bgColor: 'black',38 })}39 onKeyDown={handleKeyDown}40 ref={modalRef}41 >42 <ModalHeader>43 <ModalHeading44 className={css({45 color: 'yellow !important',46 })}47 >48 Inspectah Deck49 </ModalHeading>50 <ModalDescription>51 Swingin' through your town like your neighborhood Spider-man!52 </ModalDescription>53 </ModalHeader>54
55 <Button56 className={css({57 borderColor: 'yellow',58 color: 'yellow',59 _hover: {60 borderColor: 'yellow',61 color: 'yellow',62 },63 })}64 usage="outlined"65 onClick={close}66 >67 Close68 </Button>69 </Modal>70 </Portal>71 </div>72 )73}
API
define function Modal(props: HTMLAttributes<HTMLDialogElement>): ReactNode
define function ModalHeader(props: HTMLAttributes<HTMLDivElement>): ReactNode
define function ModalHeading(props: HTMLAttributes<HTMLParagraphElement>): ReactNode
define function ModalDescription(props: HTMLAttributes<HTMLParagraphElement>): ReactNode