### Install and Run Development Server Source: https://github.com/geist-org/geist-ui/blob/master/examples/custom-styles/README.md Install dependencies and start the development server to view your custom styles. Open http://localhost:3000 in your browser. ```bash npm i && npm run dev # or yarn && yarn dev ``` -------------------------------- ### Install Icons Package Source: https://github.com/geist-org/geist-ui/blob/master/pages/en-us/components/icons.mdx Install the @geist-ui/icons package using Yarn or npm. ```bash yarn add @geist-ui/icons ``` ```bash npm i @geist-ui/icons ``` -------------------------------- ### Next.js App Setup Source: https://github.com/geist-org/geist-ui/blob/master/pages/en-us/guide/installation.mdx Configure your Next.js project by adding GeistProvider and CssBaseline to the `_app.jsx` file for Geist UI integration. ```jsx import { GeistProvider, CssBaseline } from '@geist-ui/core' const App = ({ Component, pageProps }) => { return ( ) } export default App ``` -------------------------------- ### Run Development Server Source: https://github.com/geist-org/geist-ui/blob/master/examples/create-next-app/README.md Use npm or yarn to start the Next.js development server. Open http://localhost:3000 in your browser to view the application. ```bash npm run dev # or yarn dev ``` -------------------------------- ### Basic Tabs Example Source: https://github.com/geist-org/geist-ui/blob/master/pages/en-us/components/tabs.mdx Displays a simple tab interface with two items. Use this for basic content switching. ```jsx HTTP is stateless, but not sessionless. Between the Web browser and the server, numerous computers and machines relay the HTTP messages. ``` -------------------------------- ### Setup GeistProvider and CssBaseline Source: https://github.com/geist-org/geist-ui/blob/master/pages/en-us/guide/installation.mdx Import GeistProvider and CssBaseline into your application's entry point to enable Geist UI components and apply base styles. ```jsx import { GeistProvider, CssBaseline } from '@geist-ui/core' export default () => ( // --> base styles // --> your application ) ``` -------------------------------- ### Basic Usage Example Source: https://github.com/geist-org/geist-ui/blob/master/pages/en-us/guide/installation.mdx Demonstrates how to use Geist UI components like Page, Text, and Button within a React component. ```jsx import { Button, Page, Text } from '@geist-ui/core' const Home = () => ( Home Page ) ``` -------------------------------- ### Basic Clipboard Copy Example Source: https://github.com/geist-org/geist-ui/blob/master/pages/en-us/hooks/use-clipboard.mdx Demonstrates how to use the `useClipboard` hook to copy a string to the clipboard and display a toast notification upon success. Ensure `useToasts` is also imported and initialized. ```jsx () => { const { setToast } = useToasts() const { copy } = useClipboard() const handler = () => { copy('hello, geist-ui') setToast({ text: 'Text copied.' }) } return ( <> ) } ``` -------------------------------- ### Install Geist UI with NPM Source: https://github.com/geist-org/geist-ui/blob/master/pages/en-us/guide/installation.mdx Use this command to add the Geist UI core package to your project when using NPM. ```bash npm i @geist-ui/core ``` -------------------------------- ### Install Inter UI Font Package Source: https://github.com/geist-org/geist-ui/blob/master/pages/en-us/guide/installation.mdx Install the 'inter-ui' package using Yarn to enhance font rendering, especially for non-Latin character sets on Windows. ```bash yarn add inter-ui ``` -------------------------------- ### Pagination with Limit Source: https://github.com/geist-org/geist-ui/blob/master/pages/en-us/components/pagination.mdx Demonstrates how to control the maximum number of pages displayed using the 'limit' prop. Includes examples with different counts and limits. ```APIDOC ## Pagination with Limit The maximum number of pages that can be displayed. ### Usage ```jsx <> ``` ``` -------------------------------- ### Basic Pagination Source: https://github.com/geist-org/geist-ui/blob/master/pages/en-us/components/pagination.mdx A simple example of the Pagination component with a total count of 20 pages and an initial page set to 3. ```APIDOC ## Pagination Navigation and identification between multiple pages. ### Usage ```jsx ``` ``` -------------------------------- ### Install Geist UI with Yarn Source: https://github.com/geist-org/geist-ui/blob/master/pages/en-us/guide/installation.mdx Use this command to add the Geist UI core package to your project when using Yarn. ```bash yarn add @geist-ui/core ``` -------------------------------- ### Tooltip Placements Source: https://github.com/geist-org/geist-ui/blob/master/pages/en-us/components/tooltip.mdx Demonstrates all 12 available 'placement' options for positioning the tooltip relative to its target element. This example uses a Grid layout for organized display. ```jsx () => { const text = 'HTTP is stateless, but not sessionless' return ( topStart top topEnd leftStart rightStart left right leftEnd rightEnd bottomStart bottom bottomEnd ) } ``` -------------------------------- ### Controlling Tabs with useTabs Source: https://github.com/geist-org/geist-ui/blob/master/pages/en-us/hooks/use-tabs.mdx Example demonstrating how to use the useTabs hook to control the active tab in the Tabs component. ```APIDOC import { useTabs, Tabs, Button, Spacer } from 'components' () => { const { setState, bindings } = useTabs('1') return ( <> HTTP is stateless, but not sessionless. Introduced in HTTP/1.0, HTTP headers make this protocol easy to extend and experiment with. ) } ``` -------------------------------- ### Basic Breadcrumbs Source: https://github.com/geist-org/geist-ui/blob/master/pages/en-us/components/breadcrumbs.mdx A simple example of the Breadcrumbs component with basic items. ```APIDOC ## Breadcrumbs Show where users are in the application. ### Usage ```jsx Home Catalog Page ``` ``` -------------------------------- ### useInput Hook Signature and Usage Source: https://github.com/geist-org/geist-ui/blob/master/pages/en-us/hooks/use-input.mdx Demonstrates how to use the useInput hook to manage the state of an input component and provides an example of its returned properties. ```APIDOC ## useInput `useInput` provides automatic binding for component [Input](/en-us/components/input), which can reduce the amount of repetitive code and improve the development experience. Using this hooks behaves the same as if you had added `React.useState` manually. ### Example Usage ```javascript import { Input, useInput, Button, Spacer } from 'components' () => { const { state, setState, reset, bindings } = useInput('Geist UI') React.useEffect(() => console.log(state), [state]) return ( <> ) } ``` ### Type Definition ```ts type useInput = (initialValue: string) => { state: string setState: Dispatch> currentRef: MutableRefObject reset: () => void bindings: { value: string onChange: (event: React.ChangeEvent) => void } } ``` ### Options - **state** (`string`): The current value of the Input. - **setState** (`Dispatch>`): Function to directly set the input's state, similar to `React.setState`. - **currentRef** (`MutableRefObject`): A ref object holding the current value of the Input. - **reset** (`() => void`): A function to reset the input's value to its initial state. - **bindings** (`object`): An object containing properties (`value` and `onChange`) that can be directly spread onto the `Input` component for automatic binding. ``` -------------------------------- ### Custom Breakpoints Configuration Source: https://github.com/geist-org/geist-ui/blob/master/pages/en-us/components/grid.mdx Example of creating a custom theme with modified breakpoints for Geist UI components. ```tsx const breakpoints: GeistUIThemesBreakpoints = { xs: { min: '0', max: '650px' }, sm: { min: '650px', max: '900px' }, md: { min: '900px', max: '1280px' }, lg: { min: '1280px', max: '1920px' }, xl: { min: '1920px', max: '10000px' }, } const App = () => { const myTheme = Themes.createFromLight({ type: 'myTheme', breakpoints, }) return ( ) } ``` -------------------------------- ### Vertical Spacer Example Source: https://github.com/geist-org/geist-ui/blob/master/pages/en-us/components/spacer.mdx Demonstrates how to use the Spacer component for vertical spacing. Adjust the 'h' prop to control the amount of space. ```jsx ``` -------------------------------- ### Horizontal Spacer Example Source: https://github.com/geist-org/geist-ui/blob/master/pages/en-us/components/spacer.mdx Illustrates the use of the Spacer component for horizontal spacing. The 'w' prop controls the width of the space. ```jsx ``` -------------------------------- ### Basic Pagination Source: https://github.com/geist-org/geist-ui/blob/master/pages/en-us/components/pagination.mdx A simple pagination component with a total of 20 pages, starting on page 3. ```jsx ``` -------------------------------- ### Breadcrumbs with Next.js Source: https://github.com/geist-org/geist-ui/blob/master/pages/en-us/components/breadcrumbs.mdx Example of integrating Breadcrumbs with Next.js routing. ```APIDOC ## With NextJS Example for use with `next.js`. ### Usage ```jsx Home Components Breadcrumbs ``` ``` -------------------------------- ### Modal Component Usage Source: https://github.com/geist-org/geist-ui/blob/master/pages/en-us/components/modal.mdx Example of how to use the Modal component with the useModal hook to control visibility and display content. ```APIDOC ## Modal Component ### Description The Modal component is used to display content in a popup window. It can be controlled using the `useModal` hook. ### Usage ```javascript import { Modal, Button, useModal } from '@geist-ui/core' () => { const { visible, setVisible, bindings } = useModal() return ( <> Modal Modal with a lot of content

Modal content goes here...

setVisible(false)}>Cancel Submit
) } ``` ### Props for Modal | Attribute | Description | Type | Accepted values | Default | |---|---|---|---|---| | **visible** | open or close | `boolean` | - | `false` | | **onClose** | open event | `() => void` | - | - | | **onContentClick** | event from modal content | `(e: MouseEvent) => void` | - | - | | **wrapClassName** | className of the modal dialog | `string` | - | - | | **keyboard** | press Esc to close modal | `boolean` | - | `true` | | **disableBackdropClick** | click background and don't close | `boolean` | - | `false` | | ... | native props | `HTMLAttributes` | `'autoFocus', 'name', 'className', ...` | - | ### Props for Modal.Title | Attribute | Description | Type | Accepted values | Default | |---|---|---|---|---| | ... | native props | `HTMLAttributes` | `'id', 'className', ...` | - | ### Props for Modal.Subtitle | Attribute | Description | Type | Accepted values | Default | |---|---|---|---|---| | ... | native props | `HTMLAttributes` | `'id', 'className', ...` | - | ### Props for Modal.Content | Attribute | Description | Type | Accepted values | Default | |---|---|---|---|---| | ... | native props | `HTMLAttributes` | `'id', 'className', ...` | - | ### Props for Modal.Action | Attribute | Description | Type | Accepted values | Default | |---|---|---|---|---| | ... | native props | `HTMLAttributes` | `'id', 'className', ...` | - | ``` -------------------------------- ### Custom Server Integration Source: https://github.com/geist-org/geist-ui/blob/master/pages/en-us/guide/server-render.mdx In a custom server setup, collect Geist UI styles using CssBaseline.flush() and embed them within the HTML structure before sending the response. ```javascript import React from 'react' import ReactDOM from 'react-dom/server' import { CssBaseline } from 'geist-ui/core' import App from './app' export default (req, res) => { const app = ReactDOM.renderToString() const styles = CssBaseline.flush() const html = ReactDOM.renderToStaticMarkup( {styles}
, ) res.end('' + html) ``` -------------------------------- ### Basic Usage of useScale Source: https://github.com/geist-org/geist-ui/blob/master/pages/en-us/hooks/use-scale.mdx This example demonstrates how to use the `useScale` hook within a component to access the `SCALES` object and apply dynamic width scaling. The `withScale` HOC is used to wrap the component, enabling it to accept scale-related props. ```APIDOC ## Basic Usage of useScale ### Description This example demonstrates how to use the `useScale` hook within a component to access the `SCALES` object and apply dynamic width scaling. The `withScale` HOC is used to wrap the component, enabling it to accept scale-related props. ### Component Definition ```tsx import { withScale, useScale } from '@geist-ui/core' const MyComponent = () => { const { SCALES } = useScale() return
Scale Component
} export default withScale(MyComponent) ``` ### Usage Example ```tsx ``` ``` -------------------------------- ### Display with Shell Snippet Source: https://github.com/geist-org/geist-ui/blob/master/pages/en-us/components/display.mdx Showcase shell commands using the Snippet component within a Display. This is useful for providing installation or execution instructions. ```jsx yarn add @geist-ui/core ``` -------------------------------- ### Global Keyboard Event Listener Source: https://github.com/geist-org/geist-ui/blob/master/pages/en-us/hooks/use-keyboard.mdx Listen for global keyboard events. This example shows how to trigger an alert when Ctrl+S (or Cmd+S) is pressed. ```jsx () => { useKeyboard( () => alert('save success!'), [KeyCode.KEY_S, KeyMod.CtrlCmd] ) return
Press S to save.
} ``` -------------------------------- ### Select with Adaptive Width Source: https://github.com/geist-org/geist-ui/blob/master/pages/en-us/components/select.mdx Demonstrates how to control the width of the Select component. The first example shows truncation for overly long strings, while the second disables autoscaling to allow options to determine the width. ```jsx <> ``` -------------------------------- ### Table with Action Buttons (Update) Source: https://github.com/geist-org/geist-ui/blob/master/pages/en-us/components/table.mdx Shows how to implement an 'Update' action within a table row using custom rendering. This example modifies a specific row's data when the button is clicked, demonstrating dynamic data updates. ```jsx () => { const dataSource = [ { property: 'type', description: 'Content type', operation: '' }, { property: 'Component', description: 'DOM element to use', operation: '' }, { property: bold, description: 'Bold style', operation: '' }, ] const [data, setData] = React.useState(dataSource) const renderAction = (value, rowData, rowIndex) => { const updateHandler = () => { setData(last => { return last.map((item, dataIndex) => { if (dataIndex !== rowIndex) return item return { ...item, property: Math.random().toString(16).slice(-5) } }) }) } return ( ) } return ( setData(value)}>
) } ``` -------------------------------- ### Composing Text Components Source: https://github.com/geist-org/geist-ui/blob/master/pages/en-us/components/text.mdx Effectively stack multiple `Text` components to create complex text layouts. This example demonstrates combining paragraph and small text with different styles. ```jsx <> Specifies origins that are allowed to see values of attributes retrieved via features of the Resource Timing API, which would otherwise be reported as zero due to cross-origin restrictions. Indicates if the resource transmitted should be displayed inline (default behavior without the header), or if it should be handled like a download and the browser should present a “Save As” dialog. ``` -------------------------------- ### Handling Unconventional Defaults with useScale Source: https://github.com/geist-org/geist-ui/blob/master/pages/en-us/hooks/use-scale.mdx This example shows how to configure `useScale` to handle unconventional default values like 'auto'. When the initial value is a special character, the component won't scale by a factor, but user-defined values can still override it. ```APIDOC ## Handling Unconventional Defaults with useScale ### Description This example shows how to configure `useScale` to handle unconventional default values like 'auto'. When the initial value is a special character, the component won't scale by a factor, but user-defined values can still override it. ### Component Definition ```tsx import { withScale, useScale } from '@geist-ui/core' const MyComponent = () => { const { SCALES } = useScale() return
Fixed Component
} export default withScale(MyComponent) ``` ### Usage Example (No Scaling) ```tsx // -> The width is still "auto" // -> "auto" cannot be calculated mathematically ``` ### Usage Example (Override) ```tsx // -> The width is "100px" ``` ``` -------------------------------- ### Basic Usage Source: https://github.com/geist-org/geist-ui/blob/master/pages/en-us/hooks/use-media-query.mdx Demonstrates how to use the `useMediaQuery` hook to check for different screen size breakpoints like 'xs', 'sm', 'md', 'lg', and 'xl'. ```APIDOC ## Basic Usage This example shows how to use the `useMediaQuery` hook to detect the current screen size. ```jsx import { useMediaQuery, Code } from '@geist-ui/core' const MyComponent = () => { const isXS = useMediaQuery('xs') const isSM = useMediaQuery('sm') const isMD = useMediaQuery('md') const isLG = useMediaQuery('lg') const isXL = useMediaQuery('xl') return ( <> MediaQuery match: {isXS && 'xs'}{isSM && 'sm'}{isMD && 'md'}{isLG && 'lg'}{isXL && 'xl'}. ) } ``` ``` -------------------------------- ### Get Input Change Source: https://github.com/geist-org/geist-ui/blob/master/pages/en-us/components/input.mdx Captures and logs input changes using the 'onChange' event handler. ```jsx () => { const [value, setValue] = React.useState() const handler = (e) => { setValue(e.target.value) console.log(e.target.value) } return ( ) } ``` -------------------------------- ### Basic Drawer Usage Source: https://github.com/geist-org/geist-ui/blob/master/pages/en-us/components/drawer.mdx Demonstrates the basic implementation of a Drawer. Use the `visible` prop to control its open/closed state and `onClose` to handle closing events. ```jsx () => { const [state, setState] = React.useState(false) return (
setState(false)} placement="right"> Drawer This is a drawer

Some content contained within the drawer.

) } ``` -------------------------------- ### Creating a Custom Theme from Scratch Source: https://github.com/geist-org/geist-ui/blob/master/pages/en-us/guide/themes.mdx Use `Themes.create` to build a new theme object from an existing base theme object. This allows for extensive customization. ```jsx const myBaseTheme = { ... } const myTheme2 = Themes.create(myBaseTheme, { type: 'myTheme2', palette: { success: '#000', }, }) ``` -------------------------------- ### Basic Toggle Usage Source: https://github.com/geist-org/geist-ui/blob/master/pages/en-us/components/toggle.mdx Demonstrates the basic usage of the Toggle component, including its initial state. ```APIDOC ## Basic Toggle Usage ### Description Displays a boolean value. ### Component ```jsx ``` ``` -------------------------------- ### Basic Usage Source: https://github.com/geist-org/geist-ui/blob/master/pages/en-us/components/file-tree.mdx Demonstrates the basic usage of the Tree component, where folders and files are sorted automatically. ```APIDOC ## Tree ### Description Display a list of files and folders in a hierarchical tree structure. ### Usage ```jsx ``` ``` -------------------------------- ### Card with Divider Source: https://github.com/geist-org/geist-ui/blob/master/pages/en-us/components/card.mdx A card structured with dividers to separate distinct content sections. Useful for detailed information or step-by-step guides. ```jsx Description The Object constructor creates an object wrapper for the given value. When called in a non-constructor context, Object behaves identically to new Object(). ``` -------------------------------- ### Basic Usage Source: https://github.com/geist-org/geist-ui/blob/master/pages/en-us/hooks/use-toast.mdx Demonstrates how to use the `useToasts` hook to display a simple toast message with text and a delay. ```APIDOC ## Basic Usage This example shows the fundamental use of the `useToasts` hook to display a toast message. ### Method `useToasts` hook ### Usage ```javascript const { setToast } = useToasts() const click = () => setToast({ text: 'HTTP is stateless, but not sessionless.', delay: 2000 }) ``` ``` -------------------------------- ### Basic Button Dropdown Source: https://github.com/geist-org/geist-ui/blob/master/pages/en-us/components/button-dropdown.mdx Demonstrates the basic usage of the ButtonDropdown component. Ensure necessary imports are included. ```jsx import { ButtonDropdown, Spacer } from 'components' import { Playground, Attributes, Layout } from 'lib/components' import Plus from '@geist-ui/icons/plus' export const meta = { title: 'Button Dropdown', group: 'Navigation', index: 101, } export default () => ( Item 1 Item 2 Item 3 ) ``` -------------------------------- ### Creating a Custom Theme from Light Source: https://github.com/geist-org/geist-ui/blob/master/pages/en-us/guide/themes.mdx Use `Themes.createFromLight` to fork a new theme based on the default light theme. You can then modify properties like `palette.success`. ```jsx import { CssBaseline, GeistProvider, Themes } from '@geist-ui/core' const myTheme1 = Themes.createFromLight({ type: 'coolTheme', palette: { success: '#000', }, }) const App = () => ( ) ``` -------------------------------- ### Input Sizes Source: https://github.com/geist-org/geist-ui/blob/master/pages/en-us/components/input.mdx Demonstrates different input sizes using the 'scale' prop. ```jsx <> ``` -------------------------------- ### Responsive Grid Layout Source: https://github.com/geist-org/geist-ui/blob/master/pages/en-us/components/grid.mdx Shows how to use different Grid item sizes for different screen widths (xs, md). ```jsx ``` -------------------------------- ### Basic Page Usage Source: https://github.com/geist-org/geist-ui/blob/master/pages/en-us/components/page.mdx Demonstrates how to use the Page component to display general content. The content is centered by default. Use the MockPage to control visibility and onClose to handle closing the page. ```jsx () => { const Child = () => ( <>

Hello, Everyone.

This is a simulated page, you can click anywhere to close it.

) const [visible, setVisible] = React.useState(false) return ( <> setVisible(false)}> ) } ``` -------------------------------- ### Basic Select Usage Source: https://github.com/geist-org/geist-ui/blob/master/pages/en-us/components/select.mdx Demonstrates the basic functionality of the Select component with a placeholder and an onChange handler. ```jsx () => { const handler = val => console.log(val) return ( ) } ``` -------------------------------- ### Define Custom Scaling Unit for Multiple Components with GeistProvider Source: https://github.com/geist-org/geist-ui/blob/master/pages/en-us/guide/scale.mdx Demonstrates how to set a custom scaling unit for multiple components by creating a theme and wrapping them in `GeistProvider`. This ensures consistent scaling across a scope. ```jsx // NAME: src/app.jsx const themeType = 'myTheme' const customUnitTheme = Themes.createFromLight({ type: themeType, layout: { unit: '20px', }, }) const App = () => ( setState(false)} placement={placement}> Drawer This is a drawer

Some content contained within the drawer.

) } ``` -------------------------------- ### Display Dot with Different Types Source: https://github.com/geist-org/geist-ui/blob/master/pages/en-us/components/dot.mdx Use the `type` prop to change the appearance of the Dot component to indicate different status levels. This example shows default, success, warning, and error types. ```jsx <> ``` -------------------------------- ### Display Multi-line Code Block Source: https://github.com/geist-org/geist-ui/blob/master/pages/en-us/components/code.mdx Use the `block` prop to display multi-line code in a dedicated block. This is useful for longer code examples or scripts. Ensure the Code component and relevant data are imported. ```jsx ``` -------------------------------- ### Basic Usage Source: https://github.com/geist-org/geist-ui/blob/master/pages/en-us/components/textarea.mdx A simple Textarea for basic multi-line input. ```APIDOC ## Basic Usage ### Description This demonstrates the fundamental usage of the Textarea component for capturing multi-line user input. ### Component ```jsx