)
)
}}>
{item.text} (index #{index})
))}
)
}
```
### DragElementTargetVariants
```tsx
/**
* The `` & `` components offer a more granular control over draggable items, instead of `` that wraps each child in a `` automatically.
*/
export const DragElementTargetVariants = () => (
Draggable items that target variant groups below.
✅ Pick up a gallon of elbow grease from the hardware store.
✅ Buy a lottery ticket with the winning numbers already circled.
✅ Pick up a can of striped paint from the paint store.
✅ Get a ladder for your pet giraffe.
Lined Focus
Target variant: Lined Focus
✅ Retrieve a book on "How to Train Your Pet Rock" from the library.
✅ Attend a top-secret meeting with the Tooth Fairy to discuss dental hygiene (not
focusable).
✅ Get a selfie with Bigfoot in the deep woods.
✅ Go visit the enchanted forest to exchange potions with the woodland creatures.
Animated
Target variant: Focus
✅ Buy a gallon of polka-dotted paint.
✅ Pick up a dozen unicorn feathers from the magic shop.
✅ Visit the invisible ink store and ask for their new collection.
✅ Take a dragon for a walk in the park.
Focus
Target variant: Lined
✅ Find the end of a rainbow and collect the leprechaun's pot of gold.
✅ Pick up a lifetime supply of laughter at the comedy club.
✅ Purchase a left-handed screwdriver and a bucket of steam at the hardware store.
✅ Head to the time-traveling bookstore to find a rare edition of "Wizards and Wyrms: A
Comprehensive Guide."
Lined
Target variant: Animated
✅ Retrieve a book on "How to Train Your Pet Rock" from the library.
✅ Attend a top-secret meeting with the Tooth Fairy to discuss dental hygiene.
✅ Get a selfie with Bigfoot in the deep woods.
✅ Go visit the enchanted forest to exchange potions with the woodland creatures.
)
```
---
# Drawer
> The Drawer component displays a Modal attached to one edge of the screen.
- Package: `@fold-ui/core@0.25.1`
- Import public APIs from: `@fold-ui/core`
Drawer components provide effective means of presenting content that is not only contextually relevant to the user's current view but also discreet and easily dismissible. Examples of such content include task details, message threads, and topic deep dives.
## Public components and props
### Drawer
| Prop | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `anchor` | `"left" \| "right" \| "top" \| "bottom"` | No | — | — |
| `headerProps` | `any` | No | — | — |
| `footerProps` | `any` | No | — | — |
| `bodyProps` | `any` | No | — | — |
| `dismissOnEscape` | `boolean` | No | — | — |
| `__focusTrapTimeoutDelay` | `number` | No | — | — |
| `focusTrap` | `boolean` | No | — | — |
| `isVisible` | `boolean` | Yes | — | — |
| `footer` | `ReactElement> \| ReactElement>[]` | No | — | — |
| `header` | `ReactElement> \| ReactElement>[]` | No | — | — |
| `borderless` | `boolean` | No | — | — |
| `disableBackgroundDismiss` | `boolean` | No | — | — |
| `disableBackgroundEventPropagation` | `boolean` | No | — | — |
| `noOverlay` | `boolean` | No | — | — |
| `noDocumentScrolling` | `boolean` | No | — | — |
| `portal` | `(props: PortalProps) => ReactPortal` | No | — | — |
| `onDismiss` | `any` | No | — | — |
## CSS variables
| Variable | Default |
| --- | --- |
| `--f-drawer-speed` | `var(--f-transition-duration-slow)` |
## Examples
Examples may reference local fixture data from the Fold repository; replace those fixtures with application data.
### Imports
```tsx
import { Button, Drawer, Heading, Text, View, useVisibility } from '@fold-ui/core'
import React from 'react'
```
### Usage
```tsx
export const Usage = () => {
const { visible, show, hide } = useVisibility(false)
return (
Context is key...
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut
labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco
laboris nisi ut aliquip ex ea commodo consequat.
)
}
```
---
# Editable
> The Editable component enables users to edit simple text content inline.
- Package: `@fold-ui/core@0.25.1`
- Import public APIs from: `@fold-ui/core`
The Editable component is useful for providing users an inline experience for editing simple text content. It is suited to headings, names & other text content that is presented on a single line. Editable is not suited to large text blocks where the user needs a more traditional text input element.
## Public components and props
### Editable
| Prop | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `selectOnFocus` | `boolean` | No | — | — |
| `cursorEnd` | `boolean` | No | — | — |
| `disabled` | `boolean` | No | — | — |
| `useDoubleClick` | `boolean` | No | — | — |
| `onChange` | `any` | No | — | — |
| `onCancel` | `any` | No | — | — |
## CSS variables
| Variable | Default |
| --- | --- |
| `--f-editable-radius` | `var(--f-radius-xs)` |
| `--f-editable-padding` | `5px` |
## Examples
Examples may reference local fixture data from the Fold repository; replace those fixtures with application data.
### Imports
```tsx
import { Button, Editable, Text, View } from '@fold-ui/core'
import React, { useRef } from 'react'
```
### Usage
```tsx
export const Usage = () => {
const handleChange = (content) => console.log('content changed!', content)
const handleCancel = (previousContent) => console.log(previousContent)
return (
This is something that is editable
)
}
```
### FocusEvent
```tsx
export const FocusEvent = () => {
const editableRef = useRef({ click: () => null })
const handleChange = (content) => console.log('content changed!', content)
const handleCancel = (previousContent) => console.log(previousContent)
const handleClick = (e) => editableRef.current.click()
return (
This is something that is editable
)
}
```
### StartAtEnd
```tsx
export const StartAtEnd = () => {
const handleChange = (content) => console.log('content changed!', content)
const handleCancel = (previousContent) => console.log(previousContent)
return (
This is something that is editable
)
}
```
### SelectOnFocus
```tsx
export const SelectOnFocus = () => {
const handleChange = (content) => console.log('content changed!', content)
const handleCancel = (previousContent) => console.log(previousContent)
return (
This is something that is editable
)
}
```
---
# Form
> The Form component provides quick access to native (HTML) form elements.
- Package: `@fold-ui/core@0.25.1`
- Import public APIs from: `@fold-ui/core`
The Form component also includes convenient status wrappers that are useful for making the user aware of input states. These can include incomplete or mandatory fields, but also special input criteria such as email addresses.
## Public components and props
### FormFieldset
### Form
| Prop | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `as` | `string` | No | — | — |
### FormControl
| Prop | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `row` | `boolean` | No | — | add .f-row CSS class |
| `status` | `"error" \| "success" \| "warning"` | No | — | — |
### FormDescription
| Prop | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `as` | `"p" \| "cite" \| "label" \| "span" \| "button" \| "a" \| "legend" \| "code" \| "strong" \| "b" \| "i" \| "em" \| "mark" \| "small" \| "del" \| "ins" \| "sub" \| "sup" \| "u" \| "abbr" \| "kbd" \| "s" \| "samp" \| "blockquote"` | No | — | — |
| `size` | `Size` | No | — | — |
| `htmlFor` | `string` | No | — | — |
| `href` | `string` | No | — | — |
| `title` | `string` | No | — | — |
| `target` | `string` | No | — | — |
### FormLabel
| Prop | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `required` | `boolean` | No | — | — |
| `htmlFor` | `string` | No | — | — |
| `size` | `Size` | No | — | — |
| `as` | `"p" \| "cite" \| "label" \| "span" \| "button" \| "a" \| "legend" \| "code" \| "strong" \| "b" \| "i" \| "em" \| "mark" \| "small" \| "del" \| "ins" \| "sub" \| "sup" \| "u" \| "abbr" \| "kbd" \| "s" \| "samp" \| "blockquote"` | No | — | — |
| `href` | `string` | No | — | — |
| `title` | `string` | No | — | — |
| `target` | `string` | No | — | — |
### FormHelperText
| Prop | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `size` | `Size` | No | — | — |
| `kind` | `"error" \| "success" \| "warning" \| "info"` | No | — | — |
| `icon` | `string` | No | — | — |
| `as` | `"p" \| "cite" \| "label" \| "span" \| "button" \| "a" \| "legend" \| "code" \| "strong" \| "b" \| "i" \| "em" \| "mark" \| "small" \| "del" \| "ins" \| "sub" \| "sup" \| "u" \| "abbr" \| "kbd" \| "s" \| "samp" \| "blockquote"` | No | — | — |
| `htmlFor` | `string` | No | — | — |
| `href` | `string` | No | — | — |
| `title` | `string` | No | — | — |
| `target` | `string` | No | — | — |
## CSS variables
| Variable | Default |
| --- | --- |
| `--f-form-control-color-info` | `var(--f-color-text-weakest)` |
| `--f-form-control-color-error` | `var(--f-color-danger)` |
| `--f-form-control-color-success` | `var(--f-color-success)` |
| `--f-form-control-color-warning` | `var(--f-color-warning)` |
| `--f-form-control-spacing` | `var(--f-space-2)` |
| `--f-form-fieldset-border-radius` | `var(--f-radius)` |
| `--f-form-fieldset-legend-margin` | `var(--f-space-5)` |
| `--f-form-fieldset-legend-color` | `var(--f-color-text)` |
| `--f-form-label-required-color` | `var(--f-color-danger)` |
| `--f-form-description-color` | `var(--f-color-text-weaker)` |
## Examples
Examples may reference local fixture data from the Fold repository; replace those fixtures with application data.
### Imports
```tsx
import {
Checkbox,
Form,
FormControl,
FormDescription,
FormFieldset,
FormHelperText,
FormLabel,
IconLib,
Input,
InputControl,
InputPrefix,
Stack,
useCheck,
} from '@fold-ui/core'
import React, { useState } from 'react'
```
### Usage
```tsx
export const Usage = () => {
const [name, setName] = useState('')
return (
Full nameTo complete your profile, enter your full name
setName(e.target.value)}
/>
Please don't leave any fields blank
)
}
```
### FormAndFieldset
```tsx
export const FormAndFieldset = () => {
const [name, setName] = useState('')
return (
)
}
```
### Status
```tsx
export const Status = () => {
const [name1, setName1] = useState('')
const [name2, setName2] = useState('')
const [name3, setName3] = useState('')
return (
First nameEnter your first name
setName1(e.target.value)}
/>
Please don't leave any fields blank
Second nameEnter your second name
setName2(e.target.value)}
/>
Please don't leave any fields blank
Last nameTo complete your profile, enter your last name
setName3(e.target.value)}
/>
Please don't leave any fields blank
)
}
```
### RowLayout
```tsx
/**
* Fields can also be arranged in horizontal layouts
*/
export const RowLayout = () => {
const { checked, check } = useCheck(false)
return (
Send me marketing updates
)
}
```
---
# Grid
> The Grid component wraps "display: grid", arranging child elements within a grid structure comprised of rows and columns.
- Package: `@fold-ui/core@0.25.1`
- Import public APIs from: `@fold-ui/core`
The Grid component provides a grid-centric layout system that simplifies website & app design by incorporating rows and columns, eliminating the need for floats and positioning.
## Public components and props
### Grid
| Prop | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `autoColumns` | `string` | No | — | — |
| `autoFlow` | `string` | No | — | — |
| `autoRows` | `string` | No | — | — |
| `column` | `never` | No | — | add .f-col CSS class |
| `columns` | `number` | No | — | — |
| `minChildWidth` | `string \| number` | No | — | — |
| `row` | `never` | No | — | add .f-row CSS class |
| `templateAreas` | `string` | No | — | — |
| `templateColumns` | `string` | No | — | — |
| `templateRows` | `string` | No | — | — |
| `gap` | `string \| number` | No | — | CSS flex gap |
| `grid` | `string` | No | — | — |
### GridItem
| Prop | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `area` | `string` | No | — | — |
| `colEnd` | `number \| "auto"` | No | — | — |
| `colSpan` | `number \| "auto"` | No | — | — |
| `colStart` | `number \| "auto"` | No | — | — |
| `rowEnd` | `number \| "auto"` | No | — | — |
| `rowSpan` | `number \| "auto"` | No | — | — |
| `rowStart` | `number \| "auto"` | No | — | — |
## Examples
Examples may reference local fixture data from the Fold repository; replace those fixtures with application data.
### Imports
```tsx
import React from 'react'
import * as Token from '@fold-ui/design/tokens'
import { Grid, GridItem } from '@fold-ui/core'
```
### Usage
```tsx
export const Usage = () => {
return (
One
Two
Three
Four
Five
)
}
```
### AppLayout
```tsx
export const AppLayout = () => {
return (
Header
Navigation
Content
Side navigation
Ad space
console.log('Clicked!')}>
Footer
)
}
```
---
# Heading
> The Heading component represents an HTML heading element.
- Package: `@fold-ui/core@0.25.1`
- Import public APIs from: `@fold-ui/core`
The Heading component forms part of the Fold typography system. Please see the Design Token section for information about available options.
## Public components and props
### Heading
| Prop | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `jumbo` | `boolean` | No | — | — |
| `huge` | `boolean` | No | — | — |
| `as` | `Headings` | No | — | — |
## CSS variables
| Variable | Default |
| --- | --- |
| `--f-heading-color` | `var(--f-color-text)` |
| `--f-heading-background-color` | `transparent` |
## Examples
Examples may reference local fixture data from the Fold repository; replace those fixtures with application data.
### Imports
```tsx
import React from 'react'
import { Heading, Stack } from '@fold-ui/core'
```
### Usage
```tsx
export const Usage = () => {
return (
JumboHugeHeading h1Heading h2Heading h3Heading h4Heading h5Heading h6
)
}
```
---
# Hero template
> A polished marketing hero composed from Fold primitives and design tokens.
- Package: `@fold-ui/core@0.25.1`
- Import public APIs from: `@fold-ui/core`
Use this template as a starting point for a product landing page. It combines a compact navigation bar, focused headline, supporting copy, primary action, and decorative product tiles in one copyable Storybook recipe.
## Examples
Examples may reference local fixture data from the Fold repository; replace those fixtures with application data.
### Imports
```tsx
import { Button, Heading, IconLib, Logo, Text, View } from '@fold-ui/core'
import React from 'react'
```
### DataPlatform
```tsx
/**
* A desktop-first landing-page hero inspired by data and AI products.
* The decorative artwork is CSS-only, so the template has no image dependencies.
*/
export const DataPlatform = () => {
const navigation = ['Why Fold', 'Product', 'Solutions', 'Resources', 'About']
const BrandGlyph = ({ kind }: { kind: 'orbit' | 'bars' | 'path' | 'bow' | 'stack' }) => {
if (kind === 'orbit') {
return (
)
}
if (kind === 'bars') {
return (
)
}
if (kind === 'path') {
return (
)
}
if (kind === 'bow') {
return (
)
}
return (
)
}
const ProductTile = ({
kind,
position,
}: {
kind: 'orbit' | 'bars' | 'path' | 'bow' | 'stack'
position: string
}) => (
)
return (
Fold
{navigation.map((item) => (
{item}
))}
🇬🇧
Your future. Your
data. Your AI.
Take full control with a new data intelligence platform where you can manage all your data with
ease.
}>
Explore demo
)
}
```
---
# Hidden
> The Hidden component conceals content from the visible screen while still making it accessible to screen readers.
- Package: `@fold-ui/core@0.25.1`
- Import public APIs from: `@fold-ui/core`
Hiding content is a frequently employed method in web accessibility, allowing information to remain legible for screen readers while remaining concealed from visual clients.
## Public components and props
### Hidden
| Prop | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `as` | `string` | No | `div` | DOM element name |
## Examples
Examples may reference local fixture data from the Fold repository; replace those fixtures with application data.
### Imports
```tsx
import React from 'react'
import { Hidden, Text, View } from '@fold-ui/core'
```
### Usage
```tsx
export const Usage = () => {
return (
This is visually hidden......but not for screen-readers.
)
}
```
---
# Hooks
> Fold React Hooks provide various pieces of functionality that can make complex logic simple.
- Package: `@fold-ui/core@0.25.1`
- Import public APIs from: `@fold-ui/core`
Below are React Hooks that are available to use with Fold.
## Public components and props
### useCheck
### useConnection
### useDragging
### useInput
### setItemsSelected
### useObserver
### usePreventScrolling
### useResize
Not documented - appears experimental
### useCacheValue
### useTabVisibility
### useToggle
Not documented - appears not be used
### useTouch
Not documented and is in dev
### useId
### useVisibility
## Examples
Examples may reference local fixture data from the Fold repository; replace those fixtures with application data.
### Imports
```tsx
import {
Button,
Input,
Stack,
Text,
View,
dispatchPubsub,
documentObject,
useCacheValue,
useCheck,
useConnection,
useDragging,
useEvent,
useFocus,
useId,
useInput,
useObserver,
usePubsub,
useStorage,
useTabVisibility,
useTheme,
useTimeout,
useTimer,
useVisibility,
useWindowResize,
} from '@fold-ui/core'
import React, { useEffect, useRef, useState } from 'react'
```
### Check
```tsx
/**
* Toggle checked values on & off
*/
export const Check = () => {
const { check, checked } = useCheck()
return
}
```
### Connection
```tsx
/**
* Listen for the internet connection state
*/
export const Connection = () => {
const [connection, setConnection] = useState('online')
useConnection((online: 'restored' | 'online' | 'offline') => {
setConnection(online)
})
return {connection}
}
```
### Dragging
```tsx
/**
* Track drag state
*/
export const Dragging = () => {
const { startDragging, stopDragging, dragging } = useDragging()
return (
{dragging ? 'dragging' : 'not dragging'}
)
}
```
### Event
```tsx
/**
* Listen to window, document or DOM events
*/
export const Event = () => {
const [position, setPosition] = useState({ x: 0, y: 0 })
useEvent('mousemove', (e) => setPosition({ x: e.clientX, y: e.clientY }))
return (
Mouse position: {position.x}px, {position.y}px
)
}
```
### Focus
```tsx
/**
* Trap focus within a container, tabbing on the last element will move it to the first
*/
export const Focus = () => {
const [text, setText] = useState('')
const ref = useRef(null)
const { trapFocus } = useFocus()
return (
setText(e.target.value)}
/>
setText(e.target.value)}
/>
setText(e.target.value)}
/>
setText(e.target.value)}
/>
)
}
```
### InputField
```tsx
/**
* Shorthand hook for input elements
*/
export const InputField = () => {
const { value, setValue, onChange } = useInput('')
return (
)
}
```
### Observer
```tsx
/**
* Tracks mutations on a DOM element (experimental)
*/
export const Observer = () => {
const mutationRecord: MutationRecord = useObserver(documentObject.documentElement)
return Example coming soon
}
```
### Pubsub
```tsx
/**
* Publish & subscribe to topics application wide
*/
export const Pubsub = () => {
const [event, setEvent] = useState('Click!')
usePubsub('hooks', (message) => setEvent(message))
return
}
```
### Storage
```tsx
/**
* Interact with LocalStorage
* `getSafeStorage` returns an empty string if there is no value
*/
export const Storage = () => {
const { getStorage, getSafeStorage, setStorage, deleteStorage } = useStorage()
const { isCached, deleteCache, getSafeCache, setCache } = useCacheValue('foobar')
return Example coming soon
}
```
### TabVisibility
```tsx
/**
* Listen to tab visibility events (when a tab becomes visible or hidden)
*/
export const TabVisibility = () => {
const [text, setText] = useState('')
useTabVisibility((e) => {
const date = new Date()
const seconds = date.getSeconds()
const minutes = date.getMinutes()
const hour = date.getHours()
setText(`Time is ${hour}:${minutes}:${seconds}`)
})
return {text || 'Change tabs & come back'}
}
```
### Theme
```tsx
/**
* Fold Theme hook - please see theme documentation for more details
*/
export const Theme = () => {
const { systemTheme, getToken, getColorToken, setTheme, removeTheme, getSystemTheme, getStoredTheme } = useTheme()
return You are running {getSystemTheme()} mode.
}
```
### Timeout
```tsx
/**
* Shorthand wrapper around setTimeout
*/
export const Timeout = () => {
const [text, setText] = useState('Waiting...')
useTimeout(() => {
setText('Waited 2000ms!')
}, 2000)
return {text}
}
```
### Timer
```tsx
/**
* Another Shorthand wrapper around setTimeout, this time with a clearing mechanism
*/
export const Timer = () => {
const [text, setText] = useState('Click Here')
const { setTimer, clearTimer } = useTimer()
const handleClick = (e) => {
clearTimer()
setTimer(() => {
setText('Waited 2000ms!')
}, 2000)
}
return
}
```
### Ueid
```tsx
/**
* Generate Unique Enough ID's
*/
export const Ueid = () => {
const id = useId()
return {id}
}
```
### Visibility
```tsx
/**
* Toggle visibility states
*/
export const Visibility = () => {
const { visible, delayedShow, show, hide, toggle } = useVisibility(false)
return
}
```
### WindowResize
```tsx
/**
* Listen to window dimensions
*/
export const WindowResize = () => {
const { width, height, zoom } = useWindowResize()
return (
{width} {height} {zoom}
)
}
```
---
# Icon
> The Icon component displays any SVG icon that is set as a prop.
- Package: `@fold-ui/core@0.25.1`
- Import public APIs from: `@fold-ui/core`
Icons play a fundamental role in user experiences and serve various purposes. The Fold Icon component was developed to accommodate a maximum number of icon sets. Default icons are from [Heroicons](https://heroicons.com/).
## Public components and props
### Icon
### setAppIcons
### IconLib
### FIDescription
### FIRepeat
### FILockOpen
### FILockClosed
### FICog
### FIRotateLeft
### FIRotateRight
### FIEye
### FIEyeLine
### FIBin
### FISun
### FIMoon
### FIEyeDropper
### FIPlus
### FIMinus
### FIChevronDown
### FIChevronUp
### FIChevronRight
### FIChevronLeft
### FIImage
### FIMaximize
### FIMinimize
### FIMoreV
### FIMoreH
### FICheck
### FIX
### FIDate
### FICircle
### FIUpload
### FIPen
### FITag
### FILinkOut
### FILink
### FICopy
### FIFlag
### FINext
### FIClear
### FIDateDots
### FIGift
### FIWarning
### FIArrowDown
### FIArrowUp
### FIArrowRight
### FIArrowLeft
### FIPaperclip
### FIPlay
### FIPause
### FICheckCircle
### FIClipboard
### FITime
### FIMenu
### FISearch
### FIUser
### FIStar
### FIVideo
### FIAudio
## CSS variables
| Variable | Default |
| --- | --- |
| `--f-icon-sizing-xs` | `var(--f-icon-size-xs)` |
| `--f-icon-sizing-sm` | `var(--f-icon-size-sm)` |
| `--f-icon-sizing-md` | `var(--f-icon-size-md)` |
| `--f-icon-sizing-lg` | `var(--f-icon-size-lg)` |
| `--f-icon-sizing-xl` | `var(--f-icon-size-xl)` |
| `--f-icon-stroke-width-xs` | `2.4` |
| `--f-icon-stroke-width-sm` | `2.15` |
| `--f-icon-stroke-width-md` | `1.9` |
| `--f-icon-stroke-width-lg` | `1.5` |
| `--f-icon-stroke-width-xl` | `1.25` |
## Examples
Examples may reference local fixture data from the Fold repository; replace those fixtures with application data.
### Imports
```tsx
import * as Token from '@fold-ui/design/tokens'
import { FICircle, FISun, Icon, IconLib, Stack, Text, View, defaultIcons, setAppIcons } from '@fold-ui/core'
import React, { useLayoutEffect, useState } from 'react'
```
### Usage
```tsx
/**
* The icon prop wraps any SVG icon.
*/
export const Usage = () => {
return
}
```
### Sizes
```tsx
export const Sizes = () => {
return (
)
}
```
### IconLibrary
```tsx
/**
* The IconLib component allows you to include a pre-defined collection of icons, eliminating the need to import the SVG icon on each occasion.
* In addition, a set of icons have already been added by default when using AppContext. These include:
*
*/
export const IconLibrary = () => {
const [render, setRender] = useState(false)
useLayoutEffect(() => {
setAppIcons({ sun: FISun })
setRender(true)
}, [])
return render ? : null
}
```
### DefaultIcons
```tsx
/**
* In addition, a set of icons have already been made available by default when using Fold.
*/
export const DefaultIcons = () => {
return (
{Object.keys(defaultIcons).map((icon) => (
{icon}
))}
)
}
```
---
# If
> The If component hides content conditionally based on a true/false boolean value.
- Package: `@fold-ui/core@0.25.1`
- Import public APIs from: `@fold-ui/core`
If components are well-suited to serve as a more readable method for displaying and concealing child components.
## Public components and props
### If
| Prop | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `if` | `boolean` | Yes | — | — |
## Examples
Examples may reference local fixture data from the Fold repository; replace those fixtures with application data.
### Imports
```tsx
import React from 'react'
import { If, View } from '@fold-ui/core'
```
### Usage
```tsx
export const Usage = () => {
return (
This is visible......and this is not visible.
)
}
```
---
# Image
> The Image compoment is used to incorporate a photo or illustration.
- Package: `@fold-ui/core@0.25.1`
- Import public APIs from: `@fold-ui/core`
Use the Image component when you need to showcase an independent image that plays a vital role in the content displayed on the page.
## Public components and props
### ImagePlaceholder
### Image
| Prop | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `errorContent` | `ReactNode` | No | — | — |
| `src` | `string` | No | — | — |
| `objectPosition` | `string` | No | — | — |
| `objectFit` | `"contain" \| "cover" \| "fill"` | No | — | — |
| `alt` | `string` | No | — | — |
| `loading` | `"eager" \| "lazy"` | No | — | — |
| `crossOrigin` | `"anonymous" \| "use-credentials"` | No | — | — |
| `srcSet` | `string` | No | — | — |
| `sizes` | `xs \| sm \| md \| lg \| xl` | No | md | Size of the input |
| `fallbackSrc` | `string` | No | — | — |
| `loader` | `boolean` | No | — | — |
| `imageProps` | `any` | No | — | — |
| `placeholder` | `any` | No | — | — |
| `placeholderComponent` | `any` | No | — | — |
## CSS variables
| Variable | Default |
| --- | --- |
| `--f-image-border-radius` | `var(--f-radius)` |
| `--f-image-background-color` | `var(--f-color-surface-strong)` |
| `--f-image-placeholder-color` | `var(--f-color-surface-strongest)` |
## Examples
Examples may reference local fixture data from the Fold repository; replace those fixtures with application data.
### Imports
```tsx
import { Image, Progress, Text, View } from '@fold-ui/core'
import React from 'react'
```
### Usage
```tsx
export const Usage = () => (
)
```
### FailedToLoadImage
```tsx
export const FailedToLoadImage = () => (
Something has gone wrong!}
/>
)
```
### CustomLoadingPlaceholder
```tsx
export const CustomLoadingPlaceholder = () => {
const Custom = () => (
// load image using XMLHttpRequest first
// to display the loading progress
)
return (
)
}
```
---
# Input
> The Input component is an element designed for receiving text input from the user, and is an abstraction of the native HTML element.
- Package: `@fold-ui/core@0.25.1`
- Import public APIs from: `@fold-ui/core`
Input components are useful for generating interactive controls within web-based forms, enabling users to provide data. The Input component stands as one of the most pivotal elements, serving as the foundation for virtually all user inputs.
## Public components and props
### InputNumberControl
| Prop | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `size` | `Size` | No | — | — |
| `disableIncrease` | `boolean` | No | — | — |
| `disableDecrease` | `boolean` | No | — | — |
| `onIncrease` | `any` | No | — | — |
| `onDecrease` | `any` | No | — | — |
### InputControl
### Input
| Prop | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `size` | `Size` | No | — | — |
| `showIndicator` | `boolean` | No | — | — |
| `selectOnFocus` | `boolean` | No | — | — |
| `type` | `"number" \| "search" \| "color" \| "hidden" \| "date" \| "time" \| "text" \| "datetime-local" \| "email" \| "month" \| "password" \| "tel" \| "url" \| "week"` | No | — | — |
### InputPrefix
### InputSuffix
### PinInput
| Prop | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `disabled` | `boolean` | No | — | — |
| `size` | `Size` | No | — | — |
| `digits` | `number` | No | — | — |
| `type` | `"text" \| "password"` | No | — | — |
| `defaultValue` | `string` | Yes | — | — |
| `onChange` | `any` | No | — | — |
### TagInputField
| Prop | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `type` | `"number" \| "search" \| "color" \| "hidden" \| "date" \| "time" \| "text" \| "datetime-local" \| "email" \| "month" \| "password" \| "tel" \| "url" \| "week"` | No | — | — |
### TagInput
| Prop | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `render` | `any` | Yes | — | — |
| `size` | `Size` | No | — | — |
| `disabled` | `boolean` | No | — | — |
### InputPopover
| Prop | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `__openDelay` | `number` | No | — | — |
| `openOnFocus` | `boolean` | No | — | — |
| `id` | `string` | No | — | — |
| `firstTimeFocusOpen` | `boolean` | No | — | — |
| `defaultVisibility` | `boolean` | No | — | — |
| `addTabIndexToChild` | `boolean` | No | — | — |
| `popoverProps` | `PopoverProps` | No | — | — |
| `content` | `ReactNode` | Yes | — | — |
| `focusTrap` | `boolean` | No | — | — |
## CSS variables
| Variable | Default |
| --- | --- |
| `--f-input-background-color` | `var(--f-color-surface)` |
| `--f-input-background-color-disabled` | `var(--f-color-surface-strong)` |
| `--f-input-border-color` | `var(--f-color-border)` |
| `--f-input-border-width` | `1px` |
| `--f-input-border-color-active` | `var(--f-color-border-strong)` |
| `--f-input-color` | `var(--f-color-text-weak)` |
| `--f-input-color-placeholder` | `var(--f-color-text-weakest)` |
| `--f-input-color-disabled` | `var(--f-color-text-weakest)` |
| `--f-input-border-radius` | `var(--f-radius)` |
| `--f-input-base-padding` | `var(--f-space-3)` |
| `--f-input-padding` | `0 var(--f-input-base-padding)` |
| `--f-input-padding-tag` | `0.2rem var(--f-space-2)` |
| `--f-input-shadow` | `var(--f-shadow-sm)` |
| `--f-tag-input-min-width` | `50px` |
| `--f-tag-input-spacing` | `var(--f-space-1)` |
| `--f-input-prefix-padding` | `0 0 0 var(--f-input-base-padding)` |
| `--f-input-suffix-padding` | `0 var(--f-input-base-padding) 0 0` |
## Examples
Examples may reference local fixture data from the Fold repository; replace those fixtures with application data.
### Imports
```tsx
import {
ColorPicker,
TagInput,
TagInputField,
focusInputAtEnd,
getKey,
Heading,
IconLib,
Input,
InputControl,
InputNumberControl,
InputPrefix,
InputSuffix,
Label,
Li,
List,
Pill,
PinInput,
Popover,
Stack,
Text,
Textarea,
useVisibility,
View,
InputPopover,
} from '@fold-ui/core'
import React, { useRef, useState } from 'react'
```
### Usage
```tsx
export const Usage = () => {
const [text, setText] = useState('')
return (
setText(e.target.value)}
/>
)
}
```
### SelectOnFocus
```tsx
export const SelectOnFocus = () => {
const [text, setText] = useState('John Smith')
return (
setText(e.target.value)}
/>
)
}
```
### Sizes
```tsx
export const Sizes = () => {
const [text, setText] = useState('')
return (
setText(e.target.value)}
/>
setText(e.target.value)}
/>
setText(e.target.value)}
/>
setText(e.target.value)}
/>
setText(e.target.value)}
/>
)
}
```
### States
```tsx
export const States = () => {
const [text, setText] = useState('')
const [date, setDate] = useState(new Date().toDateString())
return (
setText(e.target.value)}
/>
setText(e.target.value)}
/>
setDate(e.target.value)}
type="datetime-local"
showIndicator
/>
)
}
```
### Types
```tsx
export const Types = () => {
const [text, setText] = useState('')
const [date, setDate] = useState(new Date().toDateString())
const [number, setNumber] = useState('')
return (
setNumber(e.target.value)}
type="number"
/>
setText(e.target.value)}
type="text"
/>
setText(e.target.value)}
type="email"
/>
setText(e.target.value)}
type="search"
/>
setText(e.target.value)}
type="tel"
/>
setText(e.target.value)}
type="url"
/>
setText(e.target.value)}
type="password"
/>
setDate(e.target.value)}
type="week"
/>
setDate(e.target.value)}
type="time"
/>
setDate(e.target.value)}
type="month"
/>
setDate(e.target.value)}
type="date"
/>
setDate(e.target.value)}
type="datetime-local"
/>
setDate(e.target.value)}
type="color"
/>
)
}
```
### Control
```tsx
export const Control = () => {
const [text, setText] = useState('')
const { show, delayedShow, hide, visible } = useVisibility(false)
const [color, setColor] = useState('#000000')
return (
console.log('Focused')}>
setText(e.target.value)}
/>
console.log('Focused')}
disabled>
setText(e.target.value)}
/>
console.log('Focused')}>
setText(e.target.value)}
/>
}>
setText(e.target.value)}
/>
)
}
```
### Number
```tsx
export const Number = () => {
const [text, setText] = useState('23')
const ref = useRef(null)
const handleIncrease = () => {
setText(+text + 1)
focusInputAtEnd(ref.current)
}
const handleDecrease = () => {
setText(+text - 1)
focusInputAtEnd(ref.current)
}
return (
console.log(e.target)}>
setText(e.target.value)}
size="md"
type="number"
ref={ref}
/>
Standalone number spinners:
)
}
```
### Pin
```tsx
export const Pin = () => (
console.log(sequence)}
/>
)
```
### WithPopover
```tsx
export const WithPopover = () => {
const [text, setText] = useState('')
return (
Please make sure your password:
Is more than 8 characters long
Does not container easily identifiable words
Contains alpha-numeric characters
Contains special characters
}>
setText(e.target.value)}
/>
)
}
```
### Tag
```tsx
export const Tag = () => {
const [selected, setSelected] = useState(['React', 'Svelte', 'Vue'])
const [text, setText] = useState('')
const handleKeyDown = (e) => {
const { isEnter } = getKey(e)
if (isEnter) {
e.preventDefault()
e.stopPropagation()
setSelected([...selected, text])
setText('')
}
}
return (
{
return selected.map((name, index) => (
{name}
))
}}>
setText(e.target.value)}
onKeyDown={handleKeyDown}
/>
)
}
```
---
# Kbd
> The keyboard key component serves the purpose of indicating which specific key or combination of keys is responsible for executing a particular action.
- Package: `@fold-ui/core@0.25.1`
- Import public APIs from: `@fold-ui/core`
The Kbd component is ideal for assisting users in learning how to navigate keyboard shortcuts or quickly activating functionality using the keyboard.
## Public components and props
### Kbd
## CSS variables
| Variable | Default |
| --- | --- |
| `--f-kbd-border-radius` | `var(--f-radius)` |
| `--f-kbd-background-color` | `var(--f-color-surface-stronger)` |
| `--f-kbd-border-color` | `var(--f-color-border-strong)` |
| `--f-kbd-color` | `var(--f-color-text-weaker)` |
## Examples
Examples may reference local fixture data from the Fold repository; replace those fixtures with application data.
### Imports
```tsx
import React from 'react'
import { Kbd, Text, View } from '@fold-ui/core'
```
### Usage
```tsx
export const Usage = () => {
return (
Pressshift&cntrl
)
}
```
---
# Layout
> Layout components enable the creation of organised and structured document layouts.
- Package: `@fold-ui/core@0.25.1`
- Import public APIs from: `@fold-ui/core`
The Layout components facilitate the quick creation of standard layouts for a wide range of applications, making them useful for developing applications, websites, and widgets (and anything else).
## Public components and props
### Header
### Footer
### App
### Main
### Content
### Sidebar
| Prop | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `left` | `boolean` | No | — | — |
| `right` | `boolean` | No | — | — |
## CSS variables
| Variable | Default |
| --- | --- |
| `--f-app-background-color` | `var(--f-color-background)` |
| `--f-sidebar-border-color` | `var(--f-color-border)` |
| `--f-sidebar-background-color` | `var(--f-color-surface)` |
| `--f-header-border-color` | `var(--f-color-border)` |
| `--f-header-background-color` | `var(--f-color-surface)` |
| `--f-footer-border-color` | `var(--f-color-border)` |
| `--f-footer-background-color` | `var(--f-color-surface)` |
## Examples
Examples may reference local fixture data from the Fold repository; replace those fixtures with application data.
### Imports
```tsx
import {
App,
Avatar,
Badge,
Card,
Content,
Flexer,
Footer,
Header,
Heading,
Main,
Navigation,
NavigationItem,
Sidebar,
Text,
View,
} from '@fold-ui/core'
import React from 'react'
```
### Usage
```tsx
export const Usage = () => (
Sidebar leftHeaderMainSidebar right
)
```
### AdvancedExample
```tsx
export const AdvancedExample = () => (
ApplicationDashboardAnalyticsProductsSettingsAnalyticsAccount settingsProjectsWork3 projectsProjects2 projects
)
```
---
# Line Chart
> The LineChart component plots one or more series of values over a shared axis.
- Package: `@fold-ui/core@0.25.1`
- Import public APIs from: `@fold-ui/core`
Line charts are useful for visualising trends over time or across an ordered set of categories. Series can be toggled via their legend, and an optional gradient area fill helps emphasise volume. Like the Sparkline, it is rendered with plain SVG and carries no charting dependencies.
## Public components and props
### LineChart
| Prop | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `data` | `LineChartSeries[]` | Yes | — | One or more series of `[label, value]` points. |
| `title` | `ReactNode` | No | — | Optional title rendered above the chart. |
| `header` | `ReactNode` | No | — | Optional content rendered to the right of the title (before the legends). |
| `height` | `number` | No | — | Height of the plot area, in pixels. CSS height |
| `area` | `boolean` | No | — | Fill the area beneath each line with a soft gradient. |
| `grid` | `boolean` | No | — | Render background gridlines. |
| `toggleable` | `boolean` | No | — | Allow series to be toggled by clicking their legend. |
| `ticks` | `number` | No | — | Number of value (Y) ticks. |
| `showPoints` | `boolean` | No | — | Show the points on the each x axis tick |
## Examples
Examples may reference local fixture data from the Fold repository; replace those fixtures with application data.
### Imports
```tsx
import * as Token from '@fold-ui/design/tokens'
import { Button, ButtonGroup, LineChart, LineChartSeries, View } from '@fold-ui/core'
import React from 'react'
```
### Usage
```tsx
export const Usage = () => (
)
```
### SingleSeriesWithArea
```tsx
export const SingleSeriesWithArea = () => (
)
```
### WithHeader
```tsx
/**
* Any node can be rendered between the title and the legends via the `header` prop.
*/
export const WithHeader = () => (
}
/>
)
```
---
# List
> The List component is utilized for depicting an HTML list element and its corresponding LI element.
- Package: `@fold-ui/core@0.25.1`
- Import public APIs from: `@fold-ui/core`
Lists are useful for creating menus and organizing information. Typically, list items are presented with bullet points in unordered lists, while in ordered lists, they are typically depicted with an ascending counter on the left, such as numbers or letters.
## Public components and props
### Li
### List
| Prop | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `as` | `"ul" \| "ol"` | No | — | — |
| `type` | `ListStyleType` | No | — | — |
| `bullet` | `string` | No | — | — |
## CSS variables
| Variable | Default |
| --- | --- |
| `--f-list-color` | `var(--f-color-text)` |
| `--f-list-padding` | `0 2rem` |
| `--f-li-spacing` | `0.3rem` |
| `--f-li-padding` | `0.1rem` |
| `--f-li-icon-margin` | `0.4rem` |
| `--f-li-line-height` | `normal` |
## Examples
Examples may reference local fixture data from the Fold repository; replace those fixtures with application data.
### Imports
```tsx
import { IconLib, Li, List } from '@fold-ui/core'
import React from 'react'
```
### Usage
```tsx
export const Usage = () => (