Marigold
Getting StartedFoundationsComponentsPatternsRecipesReleases
Discover new Tutorials!

Components

Overview

Application

MarigoldProvider
updated
RouterProvider
updated

Layout

Aside
Aspect
Breakout
Center
Columns
Container
Grid
Inline
Inset
Scrollable
Split
Stack
updated
Tiles

Form

Autocomplete
Button
updated
Calendar
Checkbox
ComboBox
DateField
DatePicker
Form
Multiselect
new
NumberField
Radio
SearchField
Select
Slider
Switch
TextArea
TextField
TimeField
new

Collection

SelectList
updated
Table
updated
Tag

Navigation

Accordion
Breadcrumbs
beta
Pagination
Tabs

Overlay

ContextualHelp
new
Dialog
Menu
Toast
beta
Tooltip
updated

Content

Badge
Body
Card
Divider
updated
Footer
Header
Headline
updated
Icon
updated
Image
Link
updated
List
updated
SectionMessage
SVG
updated
Text
updated
VisuallyHidden
updated
XLoader

Formatters

DateFormat
NumericFormat

Hooks and Utils

cn
cva
extendTheme
useAsyncListData
useListData
useResponsiveValue
useTheme

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.

To add breakpoints to your theme you have to write them as an array. You can pass the following parameters to your useResponsiveValue hook:

The first parameter of the hook will be the values as array which defines the breakpoints. The second argument must be the defaultIndex which points opn the default value.

If you want to have a look on all possible breakpoints from the theme you can have a look here.

Also with Tailwind some new class names came along which you can use to add styles by using the responsive modifiers (like: sm:text-sm).

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.

Preview
Code
md

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: October 25, 2024
Build with 🥵, 🧡 and
v14.1.1