Marigold
v18.0.0-beta.3
Marigold
v18.0.0-beta.3

Application

MarigoldProvider
RouterProvider

Layout

AppShellbeta
Aside
Aspect
Center
Columns
Container
Grid
Inline
Inset
Pagebeta
Panelbeta
Scrollable
Split
Stack
Tiles

Actions

Buttonupdated
ButtonGroupbeta
Link
LinkButton
ToggleButtonbeta

Form

Autocomplete
Calendar
Checkbox
ComboBox
DateField
DatePicker
DateRangePickerbeta
FileField
Form
NumberField
Radio
RangeCalendaralpha
SearchField
SegmentedControlbeta
Select
SelectListupdated
Slider
Switchupdated
TagFieldbeta
TextArea
TextField
TimeField

Collection

Cardupdated
Table
Tag
ActionBaralpha

Navigation

Accordion
Breadcrumbs
Pagination
Sidebarbeta
Tabs
TopNavigationbeta

Overlay

ActionMenualpha
ContextualHelp
Dialog
Drawer
Menuupdated
Toastbeta
Tooltip

Content

Badge
Descriptionalpha
Divider
EmptyStatebeta
Headline
Keyboardbeta
List
Loader
SectionMessage
SVG
Text
TextValuealpha
Titlealpha

Formatters

DateFormat
NumericFormat

Hooks and Utils

cn
cva
extendTheme
parseFormData
useAsyncListData
useLandmark
useListData
useResponsiveValueupdated
useTheme
VisuallyHidden
Components

useResponsiveValue

Hook that returns values based on screen sizes.

The useResponsiveValue is a client side hook. It can be used to return values based on the current screen size, using breakpoints from the theme theme.screens.

The first parameter of the hook is an array of values, one for each breakpoint (starting from no breakpoint, then sm, md, lg, etc.). The second parameter is the defaultIndex which points to the default value used during server-side rendering.

The breakpoints are defined as a screens object in your theme (e.g. { sm: '40rem', md: '48rem', ... }), matching Tailwind v4's responsive modifiers (like sm:text-sm). If no theme provides screens, the hook falls back to reading Tailwind v4's --breakpoint-* CSS custom properties.

Import

import { useResponsiveValue } from '@marigold/system';

Examples

Breakpoints

With the use of Tailwind CSS, some classes came along with which makes it easy to use different styles on different screen sizes. Here you can see a combination of the useResponsiveValue hook and the Tailwind screen sizes.

For example if you want to change background-color for different screen sizes you have to use this code below. You can see that according to the screen size the text value will change. You can try out yourself and resize the screen.

md
import { useResponsiveValue } from '@marigold/system';export default () => {  const value = useResponsiveValue(    ['no breakpoint', 'sm', 'md', 'lg', 'xl', '2xl'],    2  );  return (    <div className="sm:bg-lime-600 md:bg-lime-500 lg:bg-lime-400 xl:bg-lime-300 2xl:bg-lime-200">      {value}    </div>  );};

useSmallScreen

We also have a function that checks if the window is on a small screen size. This can be used if you just want to change something just on small screen size.

The example code shows that when it is a small screen the display css value will change.

import { useSmallScreen } from '@marigold/system';

const isSmallScreen = useSmallScreen();
...
<div className={cn(isSmallScreen ? 'hidden' : 'block')}>random div</div>
Last update: 3 months ago

useListData

Manages state for an immutable list data structure, and provides convenience methods to update the data over time.

useTheme

Hook that applies a theme

On this page

ImportExamplesBreakpointsuseSmallScreen