package tw

  1. Overview
  2. Docs
On This Page
  1. Core Concepts
  2. How It Works
  3. Units and Scales
  4. Usage Example
  5. Learn More
  6. Core Types
  7. Tailwind colors
  8. Color Constructors
  9. Base Styles
    1. Preflight
  10. Layout
    1. Aspect Ratio
    2. Columns
    3. Break After
    4. Break Before
    5. Break Inside
    6. Box Decoration Break
    7. Display
    8. Float
    9. Clear
    10. Isolation
    11. Object Fit
    12. Object Position
    13. Overflow
    14. Overscroll Behavior
    15. Overflow Wrap
    16. Box Sizing
    17. Position
    18. Top / Right / Bottom / Left
    19. Visibility
    20. Z-Index
  11. Flexbox & Grid
    1. Flex Basis
    2. Flex Direction
    3. Flex Wrap
    4. Flex
    5. Flex Grow
    6. Flex Shrink
    7. Order
    8. Grid Template Columns
    9. Grid Column
    10. Grid Template Rows
    11. Grid Row
    12. Grid Auto Flow
    13. Grid Auto Columns
    14. Grid Auto Rows
    15. Gap
    16. Justify Content
    17. Justify Items
    18. Justify Self
    19. Align Content
    20. Align Items
    21. Align Self
    22. Place Content
    23. Place Items
    24. Place Self
  12. Spacing
    1. Padding
    2. Margin
  13. Sizing
    1. Width
    2. Min Width
    3. Max Width
    4. Height
    5. Min Height
    6. Max Height
    7. Size
  14. Typography
    1. Font Family
    2. Font Size
    3. Font Smoothing
    4. Font Style
    5. Font Weight
    6. Font Stretch
    7. Numeric Variants
    8. Letter Spacing
    9. Line Clamp
    10. Line Height
    11. List Style Image
    12. List Style Position
    13. List Style Type
    14. Text Align
    15. Color
    16. Text Decoration Line
    17. Text Decoration Color
    18. Text Decoration Style
    19. Text Decoration Thickness
    20. Text Underline Offset
    21. Text Transform
    22. Text Overflow
    23. Text Wrap
    24. Text Indent
    25. Vertical Align
    26. White Space
    27. Word Break
    28. Overflow Wrap
    29. Hyphens
    30. Content
  15. Backgrounds
    1. Background Attachment
    2. Background Clip
    3. Background Color
    4. Background Image
    5. Background Origin
    6. Background Position
    7. Background Repeat
    8. Background Size
  16. Borders
    1. Border Radius
    2. Border Width
    3. Border Color
    4. Border Style
    5. Outline Width
    6. Outline Color
    7. Outline Style
    8. Outline Offset
    9. Side-specific border radius
    10. Corner-specific border radius
  17. Effects
    1. Box Shadow
    2. Opacity
    3. Ring Width
    4. Ring Color
    5. Ring Offset Width
    6. Ring Offset Color
    7. Text Shadow
    8. Mix Blend Mode
    9. Background Blend Mode
    10. Mask Clip
    11. Mask Composite
    12. Mask Image
    13. Mask Mode
    14. Mask Origin
    15. Mask Position
    16. Mask Repeat
    17. Mask Size
    18. Mask Type
  18. Filters
    1. Filter
    2. Backdrop Filter
  19. Tables
    1. Border Collapse
    2. Border Spacing
    3. Table Layout
    4. Caption Side
  20. Transitions & Animations
    1. Transition Property
    2. Transition Behavior
    3. Transition Duration
    4. Transition Timing Function
    5. Transition Delay
  21. Transforms
    1. Backface Visibility
    2. Perspective
    3. Perspective Origin
    4. Rotate
    5. Scale
    6. Skew
    7. Transform
    8. Transform Origin
    9. Transform Style
    10. Translate
    11. Container Query Utilities
  22. Forms
  23. Interactivity & Scroll
    1. Accent Color
    2. Caret Color
    3. Color Scheme
    4. Cursor
    5. Field Sizing
    6. User Select
    7. Pointer Events
    8. Scroll Snap Type
    9. Scroll Snap Align
    10. Scroll Snap Stop
    11. Scroll Behavior
    12. Touch Action
    13. Divide
    14. Scroll Margin
    15. Scroll Padding
    16. Appearance
    17. Resize
    18. Will Change
  24. SVG
    1. Fill
    2. Stroke
    3. Stroke Width
  25. Accessibility
    1. Forced Color Adjust
  26. Prose Typography
    1. Prose markers
  27. Class Generation & Internals
    1. CSS Generation
  28. Modifiers
    1. State Variants
    2. Group/Peer Variants
    3. Theme/Motion/Contrast
    4. Responsive Breakpoints
    5. Pseudo-elements
    6. ARIA Variants
    7. Data Attributes
    8. Prose Element Variants

Module TwSource

Type-safe CSS styling

This module provides a typed interface for generating CSS styles without writing raw CSS. It prevents typos and invalid combinations at compile-time by using OCaml's type system.

Core Concepts

  • Utility-first: Instead of writing CSS classes with multiple properties, you compose small, single-purpose utilities (e.g., bg blue for background color, p 4 for padding)
  • Type-safe: The OCaml compiler catches errors like misspelled utilities or invalid value combinations at compile time
  • Composable: Styles are composed by creating lists of utilities that work together

How It Works

1. Each function returns a value of type t representing a single style 2. Multiple styles are combined by creating a t list 3. The list is converted to CSS using to_classes 4. The resulting string is used with HTML elements

Units and Scales

  • Spacing: Integer values create spacing in 0.25rem increments. 4 = 1rem = 16px (by default)
  • Sizes: Predefined sizes like sm, md, lg provide consistent scaling
  • Colors: Colors use an optional shade parameter (50-900) where higher numbers are darker

Usage Example

let button_classes =
  to_classes
    [
      bg blue;
      text white;
      py 4;
      px 8;
      font_bold;
      rounded_md;
      hover [ bg ~shade:700 blue ];
      transition_colors;
      sm [ px 6 ];
    ]
  • The API design follows Tailwind CSS conventions
  • Colors, spacing, and sizes use consistent scales throughout
Sourcemodule Cursor : sig ... end

Cursor utilities

Sourcemodule Rule : sig ... end

CSS rule extraction — converts Tailwind utility classes into Output.t values.

Core Types

Sourcetype t

The abstract type representing a single CSS style utility.

Sourcetype color = Color.color

Abstract type for colors. Use color constructors like red, blue, etc. Colors can have shades from 50 (lightest) to 900 (darkest).

Tailwind colors

Base colors map to the Tailwind v4 palette (shades 50–950). Use bg color shade, text color shade, and border_color color shade to produce utilities.

Palettes include: black, white, gray, slate, zinc, neutral, stone, red, orange, amber, yellow, lime, green, emerald, teal, cyan, sky, blue, indigo, violet, purple, fuchsia, pink, rose.

For the full palette and OKLCH values, see

Color Constructors

Sourceval black : color

black is Tailwind black palette. See Tailwind colors.

Sourceval white : color

white is Tailwind white palette. See Tailwind colors.

Sourceval gray : color

gray is Tailwind gray palette. See Tailwind colors.

Sourceval slate : color

slate is Tailwind slate palette. See Tailwind colors.

Sourceval zinc : color

zinc is Tailwind zinc palette. See Tailwind colors.

Sourceval neutral : color

neutral is Tailwind neutral palette. See Tailwind colors.

Sourceval stone : color

stone is Tailwind stone palette. See Tailwind colors.

Sourceval red : color

red is Tailwind red palette. See Tailwind colors.

Sourceval orange : color

orange is Tailwind orange palette. See Tailwind colors.

Sourceval amber : color

amber is Tailwind amber palette. See Tailwind colors.

Sourceval yellow : color

yellow is Tailwind yellow palette. See Tailwind colors.

Sourceval lime : color

lime is Tailwind lime palette. See Tailwind colors.

Sourceval green : color

green is Tailwind green palette. See Tailwind colors.

Sourceval emerald : color

emerald is Tailwind emerald palette. See Tailwind colors.

Sourceval teal : color

teal is Tailwind teal palette. See Tailwind colors.

Sourceval cyan : color

cyan is Tailwind cyan palette. See Tailwind colors.

Sourceval sky : color

sky is Tailwind sky palette. See Tailwind colors.

Sourceval blue : color

blue is Tailwind blue palette. See Tailwind colors.

Sourceval indigo : color

indigo is Tailwind indigo palette. See Tailwind colors.

Sourceval violet : color

violet is Tailwind violet palette. See Tailwind colors.

Sourceval purple : color

purple is Tailwind purple palette. See Tailwind colors.

Sourceval fuchsia : color

fuchsia is Tailwind fuchsia palette. See Tailwind colors.

Sourceval pink : color

pink is Tailwind pink palette. See Tailwind colors.

Sourceval rose : color

rose is Tailwind rose palette. See Tailwind colors.

Sourceval hex : string -> color

hex "#1da1f2" creates a custom color from a hex string. The # prefix is optional.

Examples:

  • hex "#1da1f2" - Twitter blue with # prefix.
  • hex "ff5733" - Orange without # prefix.
  • hex "#f0f" - 3-character hex codes are supported.
Sourceval rgb : int -> int -> int -> color

rgb r g b creates a custom color from RGB values (0-255).

Examples:

  • rgb 29 161 242 - Twitter blue
  • rgb 255 87 51 - Orange

Raises Invalid_argument if any channel value is outside 0-255 range.

Base Styles

Preflight

Preflight provides Tailwind’s base CSS reset. It is included automatically when generating full CSS with this library.

Sourceval preflight : ?theme:Scheme.t -> ?placeholder_supports:Cascade.Css.t -> ?forms:bool -> unit -> Cascade.Css.t

preflight ?theme ?placeholder_supports ?forms () returns Tailwind's Preflight base reset rules, reading the --default-* font tokens through theme (default Scheme.default).

Use this to compose the base reset manually when needed. When using to_css with ~base:true (the default), the base reset is already included.

If forms is true, omits webkit datetime rules that the forms plugin provides (display:inline-flex and fields-wrapper padding) to avoid duplicates.

Usage:

  • Css.stylesheet (preflight () |> List.map (fun r -> Css.Rule r))
  • Combine with to_css output for a full stylesheet.

Layout

Aspect Ratio

Sourceval aspect_auto : t

aspect_auto sets automatic aspect ratio based on content or CSS rules.

Sourceval aspect_square : t

aspect_square sets a square 1:1 aspect ratio.

Sourceval aspect_video : t

aspect_video sets a 16:9 aspect ratio.

Sourceval aspect_ratio : int -> int -> t

aspect_ratio w h maintains element proportions of w:h.

Columns

Sourceval columns : int -> t

columns n sets column-count: n for multi-column layout.

Sourceval columns_auto : t

columns_auto sets column-count: auto.

Sourceval columns_3xs : t

columns_3xs sets column-width to the --container-3xs size.

Sourceval columns_2xs : t

columns_2xs sets column-width to the --container-2xs size.

Sourceval columns_xs : t

columns_xs sets column-width to the --container-xs size.

Sourceval columns_sm : t

columns_sm sets column-width to the --container-sm size.

Sourceval columns_md : t

columns_md sets column-width to the --container-md size.

Sourceval columns_lg : t

columns_lg sets column-width to the --container-lg size.

Sourceval columns_xl : t

columns_xl sets column-width to the --container-xl size.

Sourceval columns_2xl : t

columns_2xl sets column-width to the --container-2xl size.

Sourceval columns_3xl : t

columns_3xl sets column-width to the --container-3xl size.

Sourceval columns_4xl : t

columns_4xl sets column-width to the --container-4xl size.

Sourceval columns_5xl : t

columns_5xl sets column-width to the --container-5xl size.

Sourceval columns_6xl : t

columns_6xl sets column-width to the --container-6xl size.

Sourceval columns_7xl : t

columns_7xl sets column-width to the --container-7xl size.

Break After

Sourceval break_after_auto : t

break_after_auto sets break-after: auto.

Sourceval break_after_avoid : t

break_after_avoid sets break-after: avoid.

Sourceval break_after_all : t

break_after_all sets break-after: all.

Sourceval break_after_avoid_page : t

break_after_avoid_page sets break-after: avoid-page.

Sourceval break_after_page : t

break_after_page sets break-after: page.

Sourceval break_after_left : t

break_after_left sets break-after: left.

Sourceval break_after_right : t

break_after_right sets break-after: right.

Sourceval break_after_column : t

break_after_column sets break-after: column.

Break Before

Sourceval break_before_auto : t

break_before_auto sets break-before: auto.

Sourceval break_before_avoid : t

break_before_avoid sets break-before: avoid.

Sourceval break_before_all : t

break_before_all sets break-before: all.

Sourceval break_before_avoid_page : t

break_before_avoid_page sets break-before: avoid-page.

Sourceval break_before_page : t

break_before_page sets break-before: page.

Sourceval break_before_left : t

break_before_left sets break-before: left.

Sourceval break_before_right : t

break_before_right sets break-before: right.

Sourceval break_before_column : t

break_before_column sets break-before: column.

Break Inside

Sourceval break_inside_auto : t

break_inside_auto sets break-inside: auto.

Sourceval break_inside_avoid : t

break_inside_avoid sets break-inside: avoid.

Sourceval break_inside_avoid_page : t

break_inside_avoid_page sets break-inside: avoid-page.

Sourceval break_inside_avoid_column : t

break_inside_avoid_column sets break-inside: avoid-column.

Box Decoration Break

Sourceval box_decoration_clone : t

box_decoration_clone replicates the element's box decoration across fragment boxes.

Sourceval box_decoration_slice : t

box_decoration_slice slices the box decoration across fragment boxes.

Display

Sourceval block : t

block makes the element a block; it takes full width and stacks vertically. Default for div, p, h1–h6.

Sourceval inline : t

inline makes the element inline; it flows with text and its width is based on content. Default for span, a, strong.

Sourceval inline_block : t

inline_block flows inline but can have width/height like a block.

Sourceval table : t

table makes the element behave like a <table> element.

Sourceval hidden : t

hidden completely hides the element; no space is reserved and screen readers skip it. Use sr_only to hide visually but keep accessible.

Float

Sourceval float_left : t

float_left sets float: left.

Sourceval float_right : t

float_right sets float: right.

Sourceval float_none : t

float_none sets float: none.

Sourceval float_start : t

float_start sets float: inline-start.

Sourceval float_end : t

float_end sets float: inline-end.

Clear

Sourceval clear_left : t

clear_left clears left floats.

Sourceval clear_right : t

clear_right clears right floats.

Sourceval clear_none : t

clear_none does not clear floats.

Sourceval clear_both : t

clear_both clears floats on both sides.

Sourceval clear_start : t

clear_start clears inline-start floats.

Sourceval clear_end : t

clear_end clears inline-end floats.

Isolation

Sourceval isolate : t

isolate creates a new stacking context to isolate z-index behavior. Useful to prevent z-index values from affecting elements outside this container.

Object Fit

Sourceval object_contain : t

object_contain scales image to fit container while preserving aspect ratio. The entire image will be visible but may have empty space.

Sourceval object_cover : t

object_cover scales image to cover the entire container while preserving aspect ratio. Parts of the image may be clipped to fill the container.

Sourceval object_fill : t

object_fill stretches image to fill container, ignoring aspect ratio. May cause distortion.

Sourceval object_none : t

object_none keeps the image's original size; it may overflow or underflow the container.

Sourceval object_scale_down : t

object_scale_down scales down only if the image is larger than the container; otherwise uses the original size.

Object Position

Sourceval object_top : t

object_top sets object position to top.

Sourceval object_right : t

object_right sets object position to right.

Sourceval object_bottom : t

object_bottom sets object position to bottom.

Sourceval object_left : t

object_left sets object position to left.

Sourceval object_center : t

object_center sets object position to center.

Overflow

Sourceval overflow_auto : t

overflow_auto uses automatic overflow handling.

Sourceval overflow_hidden : t

overflow_hidden clips content that exceeds container bounds (no scrolling).

Sourceval overflow_visible : t

overflow_visible allows content to extend beyond container bounds (default).

Sourceval overflow_scroll : t

overflow_scroll always shows scrollbars even if content fits.

Sourceval overflow_x_auto : t

overflow_x_auto uses automatic horizontal overflow.

Sourceval overflow_x_hidden : t

overflow_x_hidden hides horizontal overflow.

Sourceval overflow_x_visible : t

overflow_x_visible shows horizontal overflow.

Sourceval overflow_x_scroll : t

overflow_x_scroll always shows a horizontal scrollbar.

Sourceval overflow_y_auto : t

overflow_y_auto uses automatic vertical overflow.

Sourceval overflow_y_hidden : t

overflow_y_hidden hides vertical overflow.

Sourceval overflow_y_visible : t

overflow_y_visible shows vertical overflow.

Sourceval overflow_y_scroll : t

overflow_y_scroll always shows a vertical scrollbar.

Overscroll Behavior

Sourceval overscroll_auto : t

overscroll_auto uses default scroll chaining behavior.

Sourceval overscroll_contain : t

overscroll_contain prevents scroll chaining to parent elements.

Sourceval overscroll_none : t

overscroll_none prevents scroll chaining and overscroll effects.

Sourceval overscroll_x_auto : t

overscroll_x_auto uses default horizontal overscroll behavior.

Sourceval overscroll_x_contain : t

overscroll_x_contain prevents horizontal scroll chaining.

Sourceval overscroll_x_none : t

overscroll_x_none prevents horizontal scroll chaining and effects.

Sourceval overscroll_y_auto : t

overscroll_y_auto uses default vertical overscroll behavior.

Sourceval overscroll_y_contain : t

overscroll_y_contain prevents vertical scroll chaining.

Sourceval overscroll_y_none : t

overscroll_y_none prevents vertical scroll chaining and effects.

Overflow Wrap

Sourceval wrap_normal : t

wrap_normal uses default word wrapping behavior.

Sourceval wrap_break_word : t

wrap_break_word breaks words to prevent overflow.

Sourceval wrap_anywhere : t

wrap_anywhere breaks at any character to prevent overflow.

Box Sizing

Sourceval box_border : t

box_border includes borders and padding in the element's size.

Sourceval box_content : t

box_content excludes borders and padding from the element's size.

Position

Sourceval static : t

static uses normal document flow positioning. Ignores top/right/bottom/left properties.

Sourceval relative : t

relative positions relative to the element's normal position. You can use top/right/bottom/left to nudge from the original spot. Creates positioning context for absolute children.

Sourceval absolute : t

absolute removes from normal flow and positions relative to the nearest positioned parent. Use with top/right/bottom/left for exact placement.

Example:

let badge_container = to_classes [ relative ]
let badge = to_classes [ absolute; top (-2); right (-2) ]
Sourceval fixed : t

fixed is like absolute but relative to the viewport; it stays in place when scrolling.

Sourceval sticky : t

sticky scrolls normally until it reaches a viewport edge, then sticks. Great for table headers and sidebars that follow scroll.

Top / Right / Bottom / Left

Sourceval inset_0 : t

inset_0 sets all inset values to 0.

Sourceval inset_x : int -> t

inset_x n sets horizontal inset (left and right).

Sourceval inset_x' : float -> t

inset_x' n is inset_x for a half-step scale value.

Sourceval inset_x_0 : t

inset_x_0 sets left and right to 0.

Sourceval inset_y : int -> t

inset_y n sets vertical inset (top and bottom).

Sourceval inset_y' : float -> t

inset_y' n is inset_y for a half-step scale value.

Sourceval inset_y_0 : t

inset_y_0 sets top and bottom to 0.

Sourceval top : int -> t

top n sets top position value.

Sourceval top' : float -> t

top' n is top for a half-step scale value (e.g. top' 0.5 for top-0.5).

Sourceval right : int -> t

right n sets right position value.

Sourceval right' : float -> t

right' n is right for a half-step scale value.

Sourceval bottom : int -> t

bottom n sets bottom position value.

Sourceval bottom' : float -> t

bottom' n is bottom for a half-step scale value.

Sourceval left : int -> t

left n sets left position value.

Sourceval left' : float -> t

left' n is left for a half-step scale value.

Sourceval inset : int -> t

inset n sets all position offsets (top, right, bottom, left) to the same value.

Sourceval inset' : float -> t

inset' n is inset for a half-step scale value.

Sourceval top_1_2 : t

top_1_2 positions the element at 50% from the top.

Sourceval left_1_2 : t

left_1_2 positions the element at 50% from the left.

Visibility

Sourceval visible : t

visible sets visibility: visible.

Sourceval invisible : t

invisible sets visibility: hidden while preserving layout space.

Sourceval collapse : t

collapse sets visibility: collapse.

Z-Index

Sourceval z : int -> t

z n controls stacking order - higher numbers appear on top.

Common values:

  • z 0: Default layer
  • z 10: Dropdowns, tooltips
  • z 20: Modals
  • z 30: Notifications
  • z 40: Critical overlays
  • z 50: Maximum (use sparingly)

Negative values like z (-1) place elements behind others.

Flexbox & Grid

Flex Basis

Sourceval basis_0 : t

basis_0 sets flex-basis to 0.

Sourceval basis_1 : t

basis_1 sets flex-basis to 0.25rem.

Sourceval basis_auto : t

basis_auto sets flex-basis to auto.

Sourceval basis_full : t

basis_full sets flex-basis to 100%.

Flex Direction

Sourceval flex_row : t

flex_row arranges flex items horizontally (left to right). This is the default for flex containers.

Sourceval flex_row_reverse : t

flex_row_reverse arranges flex items horizontally but reversed (right to left).

Sourceval flex_col : t

flex_col stacks flex items vertically (top to bottom). Changes the main axis to vertical.

Sourceval flex_col_reverse : t

flex_col_reverse stacks flex items vertically but reversed (bottom to top).

Flex Wrap

Sourceval flex_wrap : t

flex_wrap allows flex items to wrap onto multiple lines.

Sourceval flex_wrap_reverse : t

flex_wrap_reverse wraps flex items in reverse order.

Sourceval flex_nowrap : t

flex_nowrap prevents flex items from wrapping.

Flex

Sourceval flex : t

flex creates a flex container for flexible layouts. Children can be arranged horizontally/vertically with gaps.

Example:

let nav_item = to_classes [ flex; items_center; gap 4 ]
Sourceval inline_flex : t

inline_flex is like flex but the container itself is inline.

Sourceval flex_1 : t

flex_1 item grows and shrinks as needed, ignoring initial size. Perfect for elements that should fill available space equally.

Example:

let columns = to_classes [ flex ]
let column = to_classes [ flex_1 ]
Sourceval flex_auto : t

flex_auto item grows and shrinks but considers its content size. Good for text that should expand but not squish too much.

Sourceval flex_initial : t

flex_initial item can shrink but will not grow beyond its content. Default flex behavior.

Sourceval flex_none : t

flex_none keeps the item at its natural size; it will not grow or shrink. Use for fixed-size elements like icons or buttons.

Flex Grow

Sourceval flex_grow : t

flex_grow allows the flex item to grow.

Sourceval flex_grow_0 : t

flex_grow_0 prevents the flex item from growing.

Flex Shrink

Sourceval flex_shrink : t

flex_shrink allows the flex item to shrink.

Sourceval flex_shrink_0 : t

flex_shrink_0 prevents the flex item from shrinking.

Order

Sourceval order : int -> t

order n sets order to n.

Sourceval order_first : t

order_first sets order to minimum value.

Sourceval order_last : t

order_last sets order to maximum value.

Sourceval order_none : t

order_none sets order to 0.

Sourceval grid : t

grid creates a grid container for 2D layouts with rows and columns. More structured than flexbox.

Sourceval inline_grid : t

inline_grid is like grid but the container itself is inline.

Grid Template Columns

Sourceval grid_cols : int -> t

grid_cols n creates a grid with n equal columns.

Sourceval grid_cols_none : t

grid_cols_none removes grid template columns.

Sourceval grid_cols_subgrid : t

grid_cols_subgrid uses subgrid for columns.

Grid Column

Sourceval col_auto : t

col_auto sets grid-column to auto.

Sourceval col_span : int -> t

col_span n makes element span n columns.

Sourceval col_span_full : t

col_span_full spans all columns.

Sourceval col_start : int -> t

col_start n starts at column line n.

Sourceval col_start_auto : t

col_start_auto auto-places column start.

Sourceval col_end : int -> t

col_end n ends at column line n.

Sourceval col_end_auto : t

col_end_auto auto-places column end.

Grid Template Rows

Sourceval grid_rows : int -> t

grid_rows n creates a grid with n equal rows.

Sourceval grid_rows_none : t

grid_rows_none removes grid template rows.

Sourceval grid_rows_subgrid : t

grid_rows_subgrid uses subgrid for rows.

Grid Row

Sourceval row_auto : t

row_auto sets grid-row to auto.

Sourceval row_span : int -> t

row_span n makes element span n rows.

Sourceval row_span_full : t

row_span_full spans all rows.

Sourceval row_start : int -> t

row_start n starts at row line n.

Sourceval row_start_auto : t

row_start_auto auto-places row start.

Sourceval row_end : int -> t

row_end n ends at row line n.

Sourceval row_end_auto : t

row_end_auto auto-places row end.

Grid Auto Flow

Sourceval grid_flow_row : t

grid_flow_row sets auto-placement to fill rows.

Sourceval grid_flow_col : t

grid_flow_col sets auto-placement to fill columns.

Sourceval grid_flow_dense : t

grid_flow_dense uses dense packing algorithm.

Sourceval grid_flow_row_dense : t

grid_flow_row_dense fills rows with dense packing.

Sourceval grid_flow_col_dense : t

grid_flow_col_dense fills columns with dense packing.

Grid Auto Columns

Sourceval auto_cols_auto : t

auto_cols_auto sets implicit columns to auto.

Sourceval auto_cols_min : t

auto_cols_min sets implicit columns to min-content.

Sourceval auto_cols_max : t

auto_cols_max sets implicit columns to max-content.

Sourceval auto_cols_fr : t

auto_cols_fr sets implicit columns to 1fr.

Grid Auto Rows

Sourceval auto_rows_auto : t

auto_rows_auto sets implicit rows to auto.

Sourceval auto_rows_min : t

auto_rows_min sets implicit rows to min-content.

Sourceval auto_rows_max : t

auto_rows_max sets implicit rows to max-content.

Sourceval auto_rows_fr : t

auto_rows_fr sets implicit rows to 1fr.

Gap

Sourceval gap : int -> t

gap n sets spacing between items in flex/grid containers using Tailwind scale. More modern and flexible than using margins on children.

Example:

let button_row = to_classes [ flex; gap 4 ]
Sourceval gap' : float -> t

gap' n is gap for a half-step scale value (e.g. gap' 0.5 for gap-0.5).

Sourceval gap_x : int -> t

gap_x n sets only horizontal gaps in flex/grid containers.

Sourceval gap_x' : float -> t

gap_x' n is gap_x for a half-step scale value.

Sourceval gap_y : int -> t

gap_y n sets only vertical gaps in flex/grid containers.

Sourceval gap_y' : float -> t

gap_y' n is gap_y for a half-step scale value.

Sourceval gap_px : t

gap_px sets 1px gap between items.

Sourceval gap_full : t

gap_full sets 100% gap between items.

Justify Content

Sourceval justify_start : t

justify_start aligns content to the start of the container.

Sourceval justify_end : t

justify_end aligns content to the end of the container.

Sourceval justify_center : t

justify_center centers content in the container.

Sourceval justify_between : t

justify_between distributes items evenly with first item at start and last at end.

Sourceval justify_around : t

justify_around distributes items evenly with equal space around each item.

Sourceval justify_evenly : t

justify_evenly distributes items evenly with equal space between them.

Justify Items

Sourceval justify_items_start : t

justify_items_start justifies items to start.

Sourceval justify_items_end : t

justify_items_end justifies items to end.

Sourceval justify_items_center : t

justify_items_center centers items.

Sourceval justify_items_stretch : t

justify_items_stretch stretches items.

Justify Self

Sourceval justify_self_auto : t

justify_self_auto uses the default justification.

Sourceval justify_self_start : t

justify_self_start justifies item to the start.

Sourceval justify_self_end : t

justify_self_end justifies item to the end.

Sourceval justify_self_center : t

justify_self_center centers the item.

Sourceval justify_self_stretch : t

justify_self_stretch stretches the item.

Align Content

Sourceval content_start : t

content_start aligns lines/rows to the start of the container's cross axis. For flex containers with multiple lines or grid containers with multiple rows.

Sourceval content_end : t

content_end aligns lines/rows to the end of the container's cross axis.

Sourceval content_center : t

content_center centers lines/rows along the container's cross axis.

Sourceval content_between : t

content_between distributes lines/rows evenly: first at start, last at end.

Sourceval content_around : t

content_around distributes lines/rows evenly with equal space around each.

Sourceval content_evenly : t

content_evenly distributes lines/rows evenly with equal space between and around all.

Sourceval content_stretch : t

content_stretch stretches lines/rows to fill the container's cross axis.

Align Items

Sourceval items_start : t

items_start aligns items to the start of the cross axis.

Sourceval items_end : t

items_end aligns items to the end of the cross axis.

Sourceval items_center : t

items_center centers items along the cross axis.

Sourceval items_baseline : t

items_baseline aligns items along their text baseline.

Sourceval items_stretch : t

items_stretch stretches items to fill the cross axis (default).

Align Self

Sourceval self_auto : t

self_auto uses parent's align-items value (default).

Sourceval self_start : t

self_start aligns the item to the start of the container's cross axis.

Sourceval self_end : t

self_end aligns the item to the end of the container's cross axis.

Sourceval self_center : t

self_center centers the item along the container's cross axis.

Sourceval self_baseline : t

self_baseline aligns the item along the text baseline.

Sourceval self_stretch : t

self_stretch stretches the item to fill the container's cross axis.

Place Content

Sourceval place_content_start : t

place_content_start aligns content to start in both axes. Shorthand for align-content and justify-content.

Sourceval place_content_end : t

place_content_end aligns content to end in both axes.

Sourceval place_content_center : t

place_content_center centers content in both axes. Perfect for centering grid content.

Sourceval place_content_between : t

place_content_between distributes content with space between in both axes.

Sourceval place_content_around : t

place_content_around distributes content with space around in both axes.

Sourceval place_content_evenly : t

place_content_evenly distributes content evenly in both axes.

Sourceval place_content_stretch : t

place_content_stretch stretches content to fill both axes.

Place Items

Sourceval place_items_start : t

place_items_start aligns items to start in both axes. Shorthand for align-items and justify-items.

Sourceval place_items_end : t

place_items_end aligns items to end in both axes.

Sourceval place_items_center : t

place_items_center centers items in both axes. Common for centering grid items.

Sourceval place_items_stretch : t

place_items_stretch stretches items to fill both axes (default).

Place Self

Sourceval place_self_auto : t

place_self_auto uses parent's place-items value. Shorthand for align-self and justify-self.

Sourceval place_self_start : t

place_self_start aligns to start in both axes.

Sourceval place_self_end : t

place_self_end aligns to end in both axes.

Sourceval place_self_center : t

place_self_center centers in both axes.

Sourceval place_self_stretch : t

place_self_stretch stretches to fill both axes.

Spacing

Padding

Sourceval p : int -> t

p n sets padding (inner spacing) on all sides using Tailwind scale (n × 0.25rem).

Examples:

  • p 4: 1rem padding on all sides
  • p 0: Remove all padding
  • p 8: 2rem padding on all sides.
Sourceval p' : float -> t

p' n is p for a half-step scale value (e.g. p' 0.5 for p-0.5).

Sourceval px : int -> t

px n sets horizontal padding (left and right). Common for buttons and cards to have more horizontal than vertical padding.

Sourceval px' : float -> t

px' n is px for a half-step scale value.

Sourceval py : int -> t

py n sets vertical padding (top and bottom). Often smaller than horizontal padding for better proportions.

Sourceval py' : float -> t

py' n is py for a half-step scale value.

Sourceval pt : int -> t

pt n sets top padding.

Sourceval pt' : float -> t

pt' n is pt for a half-step scale value.

Sourceval pr : int -> t

pr n sets right padding.

Sourceval pr' : float -> t

pr' n is pr for a half-step scale value.

Sourceval pb : int -> t

pb n sets bottom padding.

Sourceval pb' : float -> t

pb' n is pb for a half-step scale value.

Sourceval pl : int -> t

pl n sets left padding.

Sourceval pl' : float -> t

pl' n is pl for a half-step scale value.

Sourceval p_px : t

p_px sets 1px padding on all sides.

Sourceval p_full : t

p_full sets 100% padding on all sides.

Sourceval px_px : t

px_px sets 1px horizontal padding.

Sourceval px_full : t

px_full sets 100% horizontal padding.

Sourceval py_px : t

py_px sets 1px vertical padding.

Sourceval py_full : t

py_full sets 100% vertical padding.

Sourceval pt_px : t

pt_px sets 1px top padding.

Sourceval pt_full : t

pt_full sets 100% top padding.

Sourceval pr_px : t

pr_px sets 1px right padding.

Sourceval pr_full : t

pr_full sets 100% right padding.

Sourceval pb_px : t

pb_px sets 1px bottom padding.

Sourceval pb_full : t

pb_full sets 100% bottom padding.

Sourceval pl_px : t

pl_px sets 1px left padding.

Sourceval pl_full : t

pl_full sets 100% left padding.

Margin

Sourceval m : int -> t

m n sets margin (outer spacing) on all sides using Tailwind scale (n × 0.25rem).

Examples:

  • m 4: 1rem margin on all sides
  • m 0: Remove all margins.
Sourceval m' : float -> t

m' n is m for a half-step scale value (e.g. m' 0.5 for m-0.5).

Sourceval mx : int -> t

mx n sets horizontal margin (left and right).

Sourceval mx' : float -> t

mx' n is mx for a half-step scale value.

Sourceval my : int -> t

my n sets vertical margin (top and bottom). Useful for spacing between sections.

Sourceval my' : float -> t

my' n is my for a half-step scale value.

Sourceval mt : int -> t

mt n sets top margin.

Sourceval mt' : float -> t

mt' n is mt for a half-step scale value.

Sourceval mr : int -> t

mr n sets right margin.

Sourceval mr' : float -> t

mr' n is mr for a half-step scale value.

Sourceval mb : int -> t

mb n sets bottom margin.

Sourceval mb' : float -> t

mb' n is mb for a half-step scale value.

Sourceval ml : int -> t

ml n sets left margin.

Sourceval ml' : float -> t

ml' n is ml for a half-step scale value.

Sourceval m_auto : t

m_auto sets auto margins on all sides (centers if width is defined).

Sourceval mx_auto : t

mx_auto centers block elements horizontally. Very commonly used.

Sourceval my_auto : t

my_auto sets auto vertical margins.

Sourceval mt_auto : t

mt_auto pushes element to bottom by setting auto top margin.

Sourceval mr_auto : t

mr_auto pushes element to left by setting auto right margin.

Sourceval mb_auto : t

mb_auto pushes element to top by setting auto bottom margin.

Sourceval ml_auto : t

ml_auto pushes element to right by setting auto left margin.

Sourceval space_x : int -> t

space_x n sets horizontal space between child elements. n is the spacing multiplier (e.g., 2 for space-x-2).

Sourceval space_x' : float -> t

space_x' n is space_x for a half-step scale value (e.g. space_x' 2.5 for space-x-2.5).

Sourceval space_y : int -> t

space_y n sets vertical space between child elements. n is the spacing multiplier (e.g., 2 for space-y-2).

Sourceval space_y' : float -> t

space_y' n is space_y for a half-step scale value.

Sizing

Width

Sourceval w : int -> t

w n sets element width using Tailwind scale (n × 0.25rem).

Sourceval w' : float -> t

w' n is w for a half-step scale value (e.g. w' 0.5 for w-0.5).

Sourceval w_full : t

w_full sets width to 100% of parent.

Sourceval w_fit : t

w_fit uses fit-content sizing.

Sourceval w_screen : t

w_screen sets width to full viewport width (100vw).

Sourceval w_min : t

w_min sets width to min-content.

Sourceval w_max : t

w_max sets width to max-content.

Min Width

Sourceval min_w : int -> t

min_w n sets minimum width using Tailwind scale.

Sourceval min_w' : float -> t

min_w' n is min_w for a half-step scale value.

Sourceval min_w_full : t

min_w_full sets minimum width to 100% of parent.

Max Width

Sourceval max_w : int -> t

max_w n sets maximum width using Tailwind scale.

Sourceval max_w' : float -> t

max_w' n is max_w for a half-step scale value.

Sourceval max_w_xs : t

max_w_xs sets maximum width to 20rem.

Sourceval max_w_sm : t

max_w_sm sets maximum width to 24rem.

Sourceval max_w_md : t

max_w_md sets maximum width to 28rem.

Sourceval max_w_lg : t

max_w_lg sets maximum width to 32rem.

Sourceval max_w_xl : t

max_w_xl sets maximum width to 36rem.

Sourceval max_w_2xl : t

max_w_2xl sets maximum width to 42rem.

Sourceval max_w_3xl : t

max_w_3xl sets maximum width to 48rem.

Sourceval max_w_4xl : t

max_w_4xl sets maximum width to 56rem.

Sourceval max_w_5xl : t

max_w_5xl sets maximum width to 64rem.

Sourceval max_w_6xl : t

max_w_6xl sets maximum width to 72rem.

Sourceval max_w_7xl : t

max_w_7xl sets maximum width to 80rem.

Sourceval max_w_none : t

max_w_none removes the maximum width constraint.

Sourceval max_w_full : t

max_w_full sets maximum width to 100% of parent.

Sourceval max_w_min : t

max_w_min sets maximum width to min-content.

Sourceval max_w_max : t

max_w_max sets maximum width to max-content.

Sourceval max_w_fit : t

max_w_fit sets maximum width to fit-content.

Sourceval max_w_prose : t

max_w_prose sets maximum width to 65ch (ideal for reading).

Sourceval max_w_screen_sm : t

max_w_screen_sm sets maximum width to 640px.

Sourceval max_w_screen_md : t

max_w_screen_md sets maximum width to 768px.

Sourceval max_w_screen_lg : t

max_w_screen_lg sets maximum width to 1024px.

Sourceval max_w_screen_xl : t

max_w_screen_xl sets maximum width to 1280px.

Sourceval max_w_screen_2xl : t

max_w_screen_2xl sets maximum width to 1536px.

Height

Sourceval h : int -> t

h n sets element height using Tailwind scale (n × 0.25rem).

Sourceval h' : float -> t

h' n is h for a half-step scale value.

Sourceval h_full : t

h_full sets height to 100% of parent.

Sourceval h_fit : t

h_fit uses fit-content sizing for height.

Sourceval h_screen : t

h_screen sets height to full viewport height (100vh).

Sourceval h_min : t

h_min sets height to min-content.

Sourceval h_max : t

h_max sets height to max-content.

Min Height

Sourceval min_h : int -> t

min_h n sets minimum height using Tailwind scale.

Sourceval min_h' : float -> t

min_h' n is min_h for a half-step scale value.

Sourceval min_h_screen : t

min_h_screen sets viewport minimum height.

Sourceval min_h_full : t

min_h_full sets minimum height to 100% of parent.

Max Height

Sourceval max_h : int -> t

max_h n sets maximum height using Tailwind scale.

Sourceval max_h' : float -> t

max_h' n is max_h for a half-step scale value (e.g. max_h' 1.5 for max-h-1.5).

Sourceval max_h_full : t

max_h_full sets maximum height to 100% of parent.

Size

Sourceval size : int -> t

size n sets both width and height using Tailwind scale (n × 0.25rem).

Sourceval size' : float -> t

size' n is size for a half-step scale value (e.g. size' 0.5 for size-0.5).

Sourceval size_auto : t

size_auto sets both width and height to auto.

Sourceval size_full : t

size_full sets both width and height to 100% of parent.

Sourceval size_min : t

size_min sets both width and height to min-content.

Sourceval size_max : t

size_max sets both width and height to max-content.

Sourceval size_fit : t

size_fit sets both width and height to fit-content.

Typography

Font Family

Sourceval font_sans : t

font_sans selects a sans-serif font family.

Sourceval font_serif : t

font_serif selects a serif font family.

Sourceval font_mono : t

font_mono selects a monospace font family.

Font Size

Sourceval text_xs : t

text_xs sets extra small text (12px) for captions, labels, and fine print.

Sourceval text_sm : t

text_sm sets small text (14px) for secondary content and form labels.

Sourceval text_base : t

text_base sets base text (16px): default body text size with good readability.

Sourceval text_lg : t

text_lg sets large text (18px) for emphasized paragraphs and lead text.

Sourceval text_xl : t

text_xl sets extra large text (20px) for section introductions.

Sourceval text_2xl : t

text_2xl sets 2× large text size (1.5rem).

Sourceval text_3xl : t

text_3xl sets 3× large text size (1.875rem).

Sourceval text_4xl : t

text_4xl sets 4× large text size (2.25rem).

Sourceval text_5xl : t

text_5xl sets 5× large text size (3rem).

Font Smoothing

Sourceval antialiased : t

antialiased enables font antialiasing for smoother text rendering.

Font Style

Sourceval italic : t

italic applies italic text style.

Sourceval not_italic : t

not_italic removes italic text style.

Font Weight

Sourceval font_thin : t

font_thin uses the thinnest font weight (100). Use sparingly; it may not be visible with all fonts.

Sourceval font_light : t

font_light uses light font weight (300) for subtle, delicate text.

Sourceval font_normal : t

font_normal uses normal font weight (400), the default for body text.

Sourceval font_medium : t

font_medium uses medium font weight (500), slightly bolder than normal; good for UI labels.

Sourceval font_semibold : t

font_semibold uses semi-bold font weight (600) for subheadings and emphasis.

Sourceval font_bold : t

font_bold uses bold font weight (700) for headings and strong emphasis.

Sourceval font_extrabold : t

font_extrabold uses extra bold font weight (800) for major headings.

Sourceval font_black : t

font_black uses the heaviest font weight (900) for maximum impact and hero text.

Font Stretch

Sourceval font_stretch_normal : t

font_stretch_normal uses the normal font stretch.

Sourceval font_stretch_condensed : t

font_stretch_condensed uses a condensed font stretch.

Sourceval font_stretch_expanded : t

font_stretch_expanded uses an expanded font stretch.

Sourceval font_stretch_percent : int -> t

font_stretch_percent n sets font stretch to n% when available.

Numeric Variants

Sourceval normal_nums : t

normal_nums resets to normal numeric glyphs.

Sourceval ordinal : t

ordinal enables ordinal markers (e.g. 1st, 2nd).

Sourceval slashed_zero : t

slashed_zero uses a zero with a slash.

Sourceval lining_nums : t

lining_nums uses lining numbers.

Sourceval oldstyle_nums : t

oldstyle_nums uses old‑style (text) figures.

Sourceval proportional_nums : t

proportional_nums uses proportional width numbers.

Sourceval tabular_nums : t

tabular_nums uses tabular width numbers.

Sourceval diagonal_fractions : t

diagonal_fractions uses diagonal fraction glyphs.

Sourceval stacked_fractions : t

stacked_fractions uses stacked fraction glyphs.

Letter Spacing

Sourceval tracking_tighter : t

tracking_tighter sets letter spacing to -0.05em.

Sourceval tracking_tight : t

tracking_tight sets letter spacing to -0.025em.

Sourceval tracking_normal : t

tracking_normal sets letter spacing to 0.

Sourceval tracking_wide : t

tracking_wide sets letter spacing to 0.025em.

Sourceval tracking_wider : t

tracking_wider sets letter spacing to 0.05em.

Sourceval tracking_widest : t

tracking_widest sets letter spacing to 0.1em.

Line Clamp

Sourceval line_clamp : int -> t

line_clamp n truncates text to n lines with ellipsis. Use 0 to remove clamping. Useful for consistent card heights.

Example:

let summary = to_classes [ line_clamp 3 ]

Line Height

Sourceval leading_none : t

leading_none sets line height to 1; text lines touch. Only for large display text.

Sourceval leading_tight : t

leading_tight sets line height to 1.25; compact spacing for headings.

Sourceval leading_snug : t

leading_snug sets line height to 1.375; slightly tighter than normal.

Sourceval leading_normal : t

leading_normal sets line height to 1.5 (default), optimal readability for body text.

Sourceval leading_relaxed : t

leading_relaxed sets line height to 1.625; more open, easier scanning for long text.

Sourceval leading_loose : t

leading_loose sets line height to 2; very open, good for short text blocks that need breathing room.

Sourceval leading : int -> t

leading n sets arbitrary line-height from the spacing scale (n * 0.25rem).

Sourceval leading' : float -> t

leading' n is leading for a half-step scale value (e.g. leading' 1.5 for leading-1.5).

List Style Image

Sourceval list_image_none : t

list_image_none removes list-style-image.

Sourceval list_image_url : string -> t

list_image_url url sets list-style-image to url.

List Style Position

Sourceval list_inside : t

list_inside places list markers inside content box.

Sourceval list_outside : t

list_outside places list markers outside content box.

List Style Type

Sourceval list_none : t

list_none removes bullets/numbers from lists.

Sourceval list_disc : t

list_disc uses disc bullets.

Sourceval list_decimal : t

list_decimal uses decimal numbering.

Text Align

Sourceval text_left : t

text_left left-aligns text.

Sourceval text_center : t

text_center center-aligns text.

Sourceval text_right : t

text_right right-aligns text.

Sourceval text_justify : t

text_justify justifies text.

Color

Sourceval text : ?opacity:int -> ?shade:int -> color -> t

text color sets text color. shade defaults to 500. opacity sets the alpha modifier (0-100).

Sourceval text_inherit : t

text_inherit inherits color from the parent element.

Sourceval text_current : t

text_current sets color to currentColor.

Sourceval text_transparent : t

text_transparent makes text fully transparent.

Text Decoration Line

Sourceval underline : t

underline applies an underlined text decoration.

Sourceval line_through : t

line_through applies a line-through text decoration.

Sourceval no_underline : t

no_underline removes text decoration.

Text Decoration Color

Sourceval decoration_color : ?shade:int -> color -> t

decoration_color ?shade color sets text-decoration color.

Text Decoration Style

Sourceval decoration_solid : t

decoration_solid sets text decoration style to solid (default).

Sourceval decoration_double : t

decoration_double sets text decoration style to a double line.

Sourceval decoration_dotted : t

decoration_dotted sets text decoration style to a dotted line.

Sourceval decoration_dashed : t

decoration_dashed sets text decoration style to a dashed line.

Sourceval decoration_wavy : t

decoration_wavy sets text decoration style to a wavy line. Good for spell check indicators.

Text Decoration Thickness

Sourceval decoration_thickness : int -> t

decoration_thickness n sets text-decoration thickness to npx.

Sourceval decoration_from_font : t

decoration_from_font uses the font's default decoration thickness.

Text Underline Offset

Sourceval underline_offset : int -> t

underline_offset n sets text underline offset to npx.

Sourceval underline_offset_auto : t

underline_offset_auto sets text underline offset to auto (browser default).

Sourceval underline_offset_0 : t

underline_offset_0 sets text underline offset to 0 (underline touches text).

Sourceval underline_offset_1 : t

underline_offset_1 sets text underline offset to 1px.

Sourceval underline_offset_2 : t

underline_offset_2 sets text underline offset to 2px.

Sourceval underline_offset_4 : t

underline_offset_4 sets text underline offset to 4px.

Sourceval underline_offset_8 : t

underline_offset_8 sets text underline offset to 8px.

Text Transform

Sourceval uppercase : t

uppercase transforms text to UPPERCASE. Useful for labels, badges, and emphasis.

Sourceval lowercase : t

lowercase transforms text to lowercase. Less common but useful for specific designs.

Sourceval capitalize : t

capitalize capitalizes the first letter of each word. Good for titles and headings.

Sourceval normal_case : t

normal_case removes text transformation (default). Use to override parent text-transform.

Text Overflow

Sourceval text_ellipsis : t

text_ellipsis uses ellipsis when text overflows.

Sourceval text_clip : t

text_clip clips overflowing text.

Text Wrap

Sourceval text_wrap : t

text_wrap enables automatic text wrapping.

Sourceval text_nowrap : t

text_nowrap disables text wrapping.

Sourceval text_balance : t

text_balance balances text across lines.

Sourceval text_pretty : t

text_pretty optimizes wrapping for readability.

Text Indent

Sourceval indent : int -> t

indent n sets text-indent to n times the spacing scale (n * 0.25rem).

Sourceval indent' : float -> t

indent' n is indent for a half-step scale value (e.g. indent' 0.5 for indent-0.5).

Vertical Align

Sourceval align_baseline : t

align_baseline sets vertical-align to baseline.

Sourceval align_top : t

align_top sets vertical-align to top.

Sourceval align_middle : t

align_middle sets vertical-align to middle.

Sourceval align_bottom : t

align_bottom sets vertical-align to bottom.

Sourceval align_text_top : t

align_text_top sets vertical-align to text-top.

Sourceval align_text_bottom : t

align_text_bottom sets vertical-align to text-bottom.

Sourceval align_sub : t

align_sub sets vertical-align to sub.

Sourceval align_super : t

align_super sets vertical-align to super.

White Space

Sourceval whitespace_normal : t

whitespace_normal uses normal whitespace handling.

Sourceval whitespace_nowrap : t

whitespace_nowrap prevents text wrapping.

Sourceval whitespace_pre : t

whitespace_pre preserves whitespace.

Sourceval whitespace_pre_line : t

whitespace_pre_line preserves line breaks.

Sourceval whitespace_pre_wrap : t

whitespace_pre_wrap preserves whitespace and wraps.

Word Break

Sourceval break_normal : t

break_normal normal word/overflow wrapping.

Sourceval break_words : t

break_words break words as needed.

Sourceval break_all : t

break_all break within words to prevent overflow.

Sourceval break_keep : t

break_keep keep words intact (keep-all).

Overflow Wrap

Sourceval overflow_wrap_normal : t

overflow_wrap_normal uses the browser default overflow wrapping behavior.

Sourceval overflow_wrap_anywhere : t

overflow_wrap_anywhere allows breaks within words to prevent overflow.

Sourceval overflow_wrap_break_word : t

overflow_wrap_break_word breaks long words to prevent overflow.

Hyphens

Sourceval hyphens_none : t

hyphens_none disables automatic hyphenation.

Sourceval hyphens_manual : t

hyphens_manual enables manual hyphenation via soft hyphen characters.

Sourceval hyphens_auto : t

hyphens_auto enables automatic hyphenation when supported.

Content

Sourceval content_none : t

content_none clears pseudo‑element content.

Sourceval content : string -> t

content value sets pseudo‑element content to value.

Backgrounds

Background Attachment

Sourceval bg_fixed : t

bg_fixed fixes the background relative to the viewport.

Sourceval bg_local : t

bg_local scrolls the background with the element's contents.

Sourceval bg_scroll : t

bg_scroll fixes the background relative to the element.

Background Clip

Sourceval bg_clip_border : t

bg_clip_border clips the background to the border box.

Sourceval bg_clip_padding : t

bg_clip_padding clips the background to the padding box.

Sourceval bg_clip_content : t

bg_clip_content clips the background to the content box.

Sourceval bg_clip_text : t

bg_clip_text clips the background to the foreground text.

Background Color

Sourceval bg : ?opacity:int -> ?shade:int -> color -> t

bg color sets the background color. shade defaults to 500.

Examples:

  • bg blue 500: Medium blue background
  • bg gray 100: Light gray background
  • bg slate 900: Very dark slate background

Shades range from 50 (lightest) to 900 (darkest).

Sourceval bg_transparent : t

bg_transparent makes background fully transparent.

Sourceval bg_current : t

bg_current sets background color to match the element's text color. If the element has text ~shade:500 blue, the background will also be blue-500. Useful for icons and decorative elements that should match text.

Background Image

Sourcetype direction =
  1. | Bottom
    (*

    Gradient towards bottom

    *)
  2. | Bottom_right
    (*

    Gradient towards bottom-right corner

    *)
  3. | Right
    (*

    Gradient towards right

    *)
  4. | Top_right
    (*

    Gradient towards top-right corner

    *)
  5. | Top
    (*

    Gradient towards top

    *)
  6. | Top_left
    (*

    Gradient towards top-left corner

    *)
  7. | Left
    (*

    Gradient towards left

    *)
  8. | Bottom_left
    (*

    Gradient towards bottom-left corner

    *)

Gradient direction variants

Sourceval bg_gradient_to : direction -> t

bg_gradient_to dir sets gradient direction using a typed direction. Combine with from_color/via_color/to_color.

Example:

let gradient =
  to_classes
    [
      bg_gradient_to Bottom;
      from_color ~shade:100 blue;
      to_color ~shade:600 blue;
    ]
Sourceval from_color : ?shade:int -> color -> t

from_color ~shade:400 blue sets the starting color of a gradient. Default shade is 500. Works with gradient direction utilities like bg_gradient_to_r.

Example:

let gradient =
  to_classes
    [
      bg_gradient_to Right;
      from_color ~shade:400 blue;
      to_color ~shade:600 purple;
    ]
Sourceval via_color : ?shade:int -> color -> t

via_color purple sets the middle color of a gradient. Default shade is 500. Creates a three-color gradient when used with bg_gradient_to and to_color.

Sourceval to_color : ?shade:int -> color -> t

to_color ~shade:600 pink sets the ending color of a gradient. Default shade is 500.

Background Origin

Sourceval bg_origin_border : t

bg_origin_border positions the background from the border box.

Sourceval bg_origin_padding : t

bg_origin_padding positions the background from the padding box.

Sourceval bg_origin_content : t

bg_origin_content positions the background from the content box.

Background Position

Sourceval bg_bottom : t

bg_bottom positions the background at the bottom.

Sourceval bg_bottom_left : t

bg_bottom_left positions the background at the bottom left.

Sourceval bg_bottom_right : t

bg_bottom_right positions the background at the bottom right.

Sourceval bg_center : t

bg_center centers the background.

Sourceval bg_left : t

bg_left positions the background at the left.

Sourceval bg_left_bottom : t

bg_left_bottom positions the background at the left bottom.

Sourceval bg_left_top : t

bg_left_top positions the background at the left top.

Sourceval bg_right : t

bg_right positions the background at the right.

Sourceval bg_right_bottom : t

bg_right_bottom positions the background at the right bottom.

Sourceval bg_right_top : t

bg_right_top positions the background at the right top.

Sourceval bg_top : t

bg_top positions the background at the top.

Sourceval bg_top_left : t

bg_top_left positions the background at the top left.

Sourceval bg_top_right : t

bg_top_right positions the background at the top right.

Background Repeat

Sourceval bg_repeat : t

bg_repeat repeats the background on both axes.

Sourceval bg_no_repeat : t

bg_no_repeat prevents the background from repeating.

Sourceval bg_repeat_x : t

bg_repeat_x repeats the background horizontally.

Sourceval bg_repeat_y : t

bg_repeat_y repeats the background vertically.

Sourceval bg_repeat_round : t

bg_repeat_round repeats and scales the background to avoid clipping.

Sourceval bg_repeat_space : t

bg_repeat_space repeats the background with space between tiles.

Background Size

Sourceval bg_auto : t

bg_auto uses the background image's intrinsic size.

Sourceval bg_cover : t

bg_cover scales the background to cover its container.

Sourceval bg_contain : t

bg_contain scales the background to fit inside its container.

Borders

Border Radius

Border Width

Sourceval border : t

border sets the default border (1px). Same as border_xs.

Sourceval border_none : t

border_none removes the border (0px).

Sourceval border_xs : t

border_xs sets extra small border (1px). Same as border.

Sourceval border_sm : t

border_sm sets small border (2px).

Sourceval border_md : t

border_md sets medium border (4px).

Sourceval border_lg : t

border_lg sets large border (4px).

Sourceval border_xl : t

border_xl sets extra large border (8px).

Sourceval border_2xl : t

border_2xl sets 2× large border (8px).

Sourceval border_3xl : t

border_3xl sets 3× large border (8px).

Sourceval border_full : t

border_full sets full border (8px).

Sourceval border_t : t

border_t sets top border (1px).

Sourceval border_r : t

border_r sets right border (1px).

Sourceval border_b : t

border_b sets bottom border (1px).

Sourceval border_l : t

border_l sets left border (1px).

Border Color

Sourceval border_color : ?opacity:int -> ?shade:int -> color -> t

border_color color sets the border color. shade defaults to 500. opacity sets the alpha modifier (0-100).

Sourceval border_transparent : t

border_transparent makes border fully transparent.

Sourceval border_current : t

border_current sets border color to match the text color. For example:

let danger_border =
  to_classes [ text ~shade:600 red; border_xs; border_current ]

This is the default behavior in Tailwind v4, but can be explicitly set.

Sourceval border_inherit : t

border_inherit inherits the border color.

Border Style

Sourceval border_solid : t

border_solid uses a solid border style.

Sourceval border_dashed : t

border_dashed uses a dashed border style.

Sourceval border_dotted : t

border_dotted uses a dotted border style.

Sourceval border_double : t

border_double uses a double border style.

Outline Width

Sourceval outline_width : int -> t

outline_width n sets outline width to n pixels. The zero value emits outline-0.

Outline Color

Sourceval outline_color : ?opacity:int -> ?shade:int -> color -> t

outline_color color sets the outline color. shade defaults to 500 and opacity sets the alpha modifier (0-100).

Sourceval outline_transparent : t

outline_transparent makes the outline fully transparent.

Sourceval outline_current : t

outline_current uses currentColor for the outline.

Sourceval outline_inherit : t

outline_inherit inherits the outline color.

Outline Style

Sourceval outline_none : t

outline_none removes the outline.

Outline Offset

Sourceval outline_offset_0 : t

outline_offset_0 sets outline offset to 0px.

Sourceval outline_offset_1 : t

outline_offset_1 sets outline offset to 1px.

Sourceval outline_offset_2 : t

outline_offset_2 sets outline offset to 2px.

Sourceval outline_offset_4 : t

outline_offset_4 sets outline offset to 4px.

Sourceval outline_offset_8 : t

outline_offset_8 sets outline offset to 8px.

Sourceval rounded_none : t

rounded_none sets sharp corners (0px).

Sourceval rounded_xs : t

rounded_xs sets extra-small rounding (2px).

Sourceval rounded_sm : t

rounded_sm sets subtle rounding (2px).

Sourceval rounded : t

rounded sets default rounding (4px). Same as rounded_md.

Sourceval rounded_md : t

rounded_md sets medium rounding (6px).

Sourceval rounded_lg : t

rounded_lg sets noticeably rounded corners (8px).

Sourceval rounded_xl : t

rounded_xl sets extra rounded corners (12px).

Sourceval rounded_2xl : t

rounded_2xl sets 2× rounded corners (16px).

Sourceval rounded_3xl : t

rounded_3xl sets 3× rounded corners (24px).

Sourceval rounded_4xl : t

rounded_4xl sets 4× rounded corners (32px).

Sourceval rounded_full : t

rounded_full sets fully rounded corners (9999px). Makes circles/pills.

Side-specific border radius

Round specific sides (top, right, bottom, left) with consistent radius values.

Sourceval rounded_t : t

rounded_t rounds the top corners with the default radius.

Sourceval rounded_t_none : t

rounded_t_none sets no rounding on top corners.

Sourceval rounded_t_xs : t

rounded_t_xs sets extra-small rounding on top corners.

Sourceval rounded_t_sm : t

rounded_t_sm sets subtle rounding on top corners.

Sourceval rounded_t_md : t

rounded_t_md sets medium rounding on top corners.

Sourceval rounded_t_lg : t

rounded_t_lg sets large rounding on top corners.

Sourceval rounded_t_xl : t

rounded_t_xl sets extra large rounding on top corners.

Sourceval rounded_t_2xl : t

rounded_t_2xl sets 2× rounding on top corners.

Sourceval rounded_t_3xl : t

rounded_t_3xl sets 3× rounding on top corners.

Sourceval rounded_t_4xl : t

rounded_t_4xl sets 4× rounding on top corners.

Sourceval rounded_t_full : t

rounded_t_full sets full rounding on top corners.

Sourceval rounded_r : t

rounded_r rounds the right corners with the default radius.

Sourceval rounded_r_none : t

rounded_r_none sets no rounding on right corners.

Sourceval rounded_r_xs : t

rounded_r_xs sets extra-small rounding on right corners.

Sourceval rounded_r_sm : t

rounded_r_sm sets subtle rounding on right corners.

Sourceval rounded_r_md : t

rounded_r_md sets medium rounding on right corners.

Sourceval rounded_r_lg : t

rounded_r_lg sets large rounding on right corners.

Sourceval rounded_r_xl : t

rounded_r_xl sets extra large rounding on right corners.

Sourceval rounded_r_2xl : t

rounded_r_2xl sets 2× rounding on right corners.

Sourceval rounded_r_3xl : t

rounded_r_3xl sets 3× rounding on right corners.

Sourceval rounded_r_4xl : t

rounded_r_4xl sets 4× rounding on right corners.

Sourceval rounded_r_full : t

rounded_r_full sets full rounding on right corners.

Sourceval rounded_b : t

rounded_b rounds the bottom corners with the default radius.

Sourceval rounded_b_none : t

rounded_b_none sets no rounding on bottom corners.

Sourceval rounded_b_xs : t

rounded_b_xs sets extra-small rounding on bottom corners.

Sourceval rounded_b_sm : t

rounded_b_sm sets subtle rounding on bottom corners.

Sourceval rounded_b_md : t

rounded_b_md sets medium rounding on bottom corners.

Sourceval rounded_b_lg : t

rounded_b_lg sets large rounding on bottom corners.

Sourceval rounded_b_xl : t

rounded_b_xl sets extra large rounding on bottom corners.

Sourceval rounded_b_2xl : t

rounded_b_2xl sets 2× rounding on bottom corners.

Sourceval rounded_b_3xl : t

rounded_b_3xl sets 3× rounding on bottom corners.

Sourceval rounded_b_4xl : t

rounded_b_4xl sets 4× rounding on bottom corners.

Sourceval rounded_b_full : t

rounded_b_full sets full rounding on bottom corners.

Sourceval rounded_l : t

rounded_l rounds the left corners with the default radius.

Sourceval rounded_l_none : t

rounded_l_none sets no rounding on left corners.

Sourceval rounded_l_xs : t

rounded_l_xs sets extra-small rounding on left corners.

Sourceval rounded_l_sm : t

rounded_l_sm sets subtle rounding on left corners.

Sourceval rounded_l_md : t

rounded_l_md sets medium rounding on left corners.

Sourceval rounded_l_lg : t

rounded_l_lg sets large rounding on left corners.

Sourceval rounded_l_xl : t

rounded_l_xl sets extra large rounding on left corners.

Sourceval rounded_l_2xl : t

rounded_l_2xl sets 2× rounding on left corners.

Sourceval rounded_l_3xl : t

rounded_l_3xl sets 3× rounding on left corners.

Sourceval rounded_l_4xl : t

rounded_l_4xl sets 4× rounding on left corners.

Sourceval rounded_l_full : t

rounded_l_full sets full rounding on left corners.

Corner-specific border radius

Round individual corners (top-left, top-right, bottom-right, bottom-left).

Sourceval rounded_tl : t

rounded_tl rounds the top-left corner with the default radius.

Sourceval rounded_tl_none : t

rounded_tl_none sets no rounding on top-left corner.

Sourceval rounded_tl_xs : t

rounded_tl_xs sets extra-small rounding on top-left corner.

Sourceval rounded_tl_sm : t

rounded_tl_sm sets subtle rounding on top-left corner.

Sourceval rounded_tl_md : t

rounded_tl_md sets medium rounding on top-left corner.

Sourceval rounded_tl_lg : t

rounded_tl_lg sets large rounding on top-left corner.

Sourceval rounded_tl_xl : t

rounded_tl_xl sets extra large rounding on top-left corner.

Sourceval rounded_tl_2xl : t

rounded_tl_2xl sets 2× rounding on top-left corner.

Sourceval rounded_tl_3xl : t

rounded_tl_3xl sets 3× rounding on top-left corner.

Sourceval rounded_tl_4xl : t

rounded_tl_4xl sets 4× rounding on top-left corner.

Sourceval rounded_tl_full : t

rounded_tl_full sets full rounding on top-left corner.

Sourceval rounded_tr : t

rounded_tr rounds the top-right corner with the default radius.

Sourceval rounded_tr_none : t

rounded_tr_none sets no rounding on top-right corner.

Sourceval rounded_tr_xs : t

rounded_tr_xs sets extra-small rounding on top-right corner.

Sourceval rounded_tr_sm : t

rounded_tr_sm sets subtle rounding on top-right corner.

Sourceval rounded_tr_md : t

rounded_tr_md sets medium rounding on top-right corner.

Sourceval rounded_tr_lg : t

rounded_tr_lg sets large rounding on top-right corner.

Sourceval rounded_tr_xl : t

rounded_tr_xl sets extra large rounding on top-right corner.

Sourceval rounded_tr_2xl : t

rounded_tr_2xl sets 2× rounding on top-right corner.

Sourceval rounded_tr_3xl : t

rounded_tr_3xl sets 3× rounding on top-right corner.

Sourceval rounded_tr_4xl : t

rounded_tr_4xl sets 4× rounding on top-right corner.

Sourceval rounded_tr_full : t

rounded_tr_full sets full rounding on top-right corner.

Sourceval rounded_br : t

rounded_br rounds the bottom-right corner with the default radius.

Sourceval rounded_br_none : t

rounded_br_none sets no rounding on bottom-right corner.

Sourceval rounded_br_xs : t

rounded_br_xs sets extra-small rounding on bottom-right corner.

Sourceval rounded_br_sm : t

rounded_br_sm sets subtle rounding on bottom-right corner.

Sourceval rounded_br_md : t

rounded_br_md sets medium rounding on bottom-right corner.

Sourceval rounded_br_lg : t

rounded_br_lg sets large rounding on bottom-right corner.

Sourceval rounded_br_xl : t

rounded_br_xl sets extra large rounding on bottom-right corner.

Sourceval rounded_br_2xl : t

rounded_br_2xl sets 2× rounding on bottom-right corner.

Sourceval rounded_br_3xl : t

rounded_br_3xl sets 3× rounding on bottom-right corner.

Sourceval rounded_br_4xl : t

rounded_br_4xl sets 4× rounding on bottom-right corner.

Sourceval rounded_br_full : t

rounded_br_full sets full rounding on bottom-right corner.

Sourceval rounded_bl : t

rounded_bl rounds the bottom-left corner with the default radius.

Sourceval rounded_bl_none : t

rounded_bl_none sets no rounding on bottom-left corner.

Sourceval rounded_bl_xs : t

rounded_bl_xs sets extra-small rounding on bottom-left corner.

Sourceval rounded_bl_sm : t

rounded_bl_sm sets subtle rounding on bottom-left corner.

Sourceval rounded_bl_md : t

rounded_bl_md sets medium rounding on bottom-left corner.

Sourceval rounded_bl_lg : t

rounded_bl_lg sets large rounding on bottom-left corner.

Sourceval rounded_bl_xl : t

rounded_bl_xl sets extra large rounding on bottom-left corner.

Sourceval rounded_bl_2xl : t

rounded_bl_2xl sets 2× rounding on bottom-left corner.

Sourceval rounded_bl_3xl : t

rounded_bl_3xl sets 3× rounding on bottom-left corner.

Sourceval rounded_bl_4xl : t

rounded_bl_4xl sets 4× rounding on bottom-left corner.

Sourceval rounded_bl_full : t

rounded_bl_full sets full rounding on bottom-left corner.

Effects

Box Shadow

Sourceval shadow_none : t

shadow_none removes the shadow.

Sourceval shadow_2xs : t

shadow_2xs applies the smallest shadow.

Sourceval shadow_xs : t

shadow_xs applies an extra-small shadow.

Sourceval shadow_sm : t

shadow_sm applies a subtle shadow for cards.

Sourceval shadow : t

shadow applies the default shadow. Same as shadow_md.

Sourceval shadow_md : t

shadow_md applies a medium shadow. Same as shadow.

Sourceval shadow_lg : t

shadow_lg applies a large shadow for modals and dropdowns.

Sourceval shadow_xl : t

shadow_xl applies an extra large shadow.

Sourceval shadow_2xl : t

shadow_2xl applies a 2× large shadow.

Sourceval shadow_inner : t

shadow_inner applies an inset shadow for a pressed/sunken effect.

Opacity

Sourceval opacity : int -> t

opacity n controls transparency (0-100).

  • 0: Fully transparent (invisible but takes space)
  • 50: Half transparent
  • 100: Fully opaque (default).
Sourceval ring_none : t

ring_none removes the ring.

Sourceval ring_xs : t

ring_xs sets an extra small ring (1px).

Sourceval ring_sm : t

ring_sm sets a small ring (2px).

Sourceval ring : t

ring applies the default ring (3px). Same as ring_md.

Sourceval ring_md : t

ring_md sets a medium ring (3px). Same as ring.

Sourceval ring_lg : t

ring_lg sets a large ring (4px).

Sourceval ring_xl : t

ring_xl sets an extra large ring (8px).

Rings use box-shadow and don't affect layout. By default, rings are blue with 50% opacity. To customize:

  • Use ring_color to change color: ring_sm; ring_color purple
  • Rings are often used for focus states: on_focus [ ring ]
  • Unlike borders, rings don't take up space in the layout.

Ring Width

Ring Color

Sourceval ring_color : ?opacity:int -> ?shade:int -> color -> t

ring_color color sets the color of outline rings. Use ~shade to pick a shade (default 500) and ~opacity to set opacity as a percentage.

Ring Offset Width

Sourceval ring_offset_width : int -> t

ring_offset_width n sets the ring offset width to n pixels.

Ring Offset Color

Sourceval ring_offset_color : ?opacity:int -> ?shade:int -> color -> t

ring_offset_color color sets the ring offset color. shade defaults to 500 and opacity sets the alpha modifier (0-100).

Sourceval ring_offset_transparent : t

ring_offset_transparent makes the ring offset transparent.

Sourceval ring_offset_current : t

ring_offset_current uses currentColor for the ring offset.

Sourceval ring_offset_inherit : t

ring_offset_inherit inherits the ring offset color.

Text Shadow

Sourceval text_shadow_none : t

text_shadow_none removes the text shadow (text-shadow: none).

Sourceval text_shadow_2xs : t

text_shadow_2xs applies the 2xs text shadow.

Sourceval text_shadow_xs : t

text_shadow_xs applies the xs text shadow.

Sourceval text_shadow_sm : t

text_shadow_sm applies the small text shadow.

Sourceval text_shadow_md : t

text_shadow_md applies the medium text shadow.

Sourceval text_shadow_lg : t

text_shadow_lg applies the large text shadow.

Sourceval text_shadow_arbitrary : string -> t

text_shadow_arbitrary s sets an arbitrary text-shadow value s.

Mix Blend Mode

Sourceval mix_blend_normal : t

mix_blend_normal sets mix-blend-mode: normal.

Sourceval mix_blend_multiply : t

mix_blend_multiply sets mix-blend-mode: multiply.

Sourceval mix_blend_screen : t

mix_blend_screen sets mix-blend-mode: screen.

Sourceval mix_blend_overlay : t

mix_blend_overlay sets mix-blend-mode: overlay.

Sourceval mix_blend_darken : t

mix_blend_darken sets mix-blend-mode: darken.

Sourceval mix_blend_lighten : t

mix_blend_lighten sets mix-blend-mode: lighten.

Sourceval mix_blend_color_dodge : t

mix_blend_color_dodge sets mix-blend-mode: color-dodge.

Sourceval mix_blend_color_burn : t

mix_blend_color_burn sets mix-blend-mode: color-burn.

Sourceval mix_blend_hard_light : t

mix_blend_hard_light sets mix-blend-mode: hard-light.

Sourceval mix_blend_soft_light : t

mix_blend_soft_light sets mix-blend-mode: soft-light.

Sourceval mix_blend_difference : t

mix_blend_difference sets mix-blend-mode: difference.

Sourceval mix_blend_exclusion : t

mix_blend_exclusion sets mix-blend-mode: exclusion.

Sourceval mix_blend_hue : t

mix_blend_hue sets mix-blend-mode: hue.

Sourceval mix_blend_saturation : t

mix_blend_saturation sets mix-blend-mode: saturation.

Sourceval mix_blend_color : t

mix_blend_color sets mix-blend-mode: color.

Sourceval mix_blend_luminosity : t

mix_blend_luminosity sets mix-blend-mode: luminosity.

Sourceval mix_blend_plus_darker : t

mix_blend_plus_darker sets mix-blend-mode: plus-darker.

Sourceval mix_blend_plus_lighter : t

mix_blend_plus_lighter sets mix-blend-mode: plus-lighter.

Background Blend Mode

Sourceval bg_blend_normal : t

bg_blend_normal uses normal background blending.

Sourceval bg_blend_multiply : t

bg_blend_multiply uses multiply background blending.

Sourceval bg_blend_screen : t

bg_blend_screen uses screen background blending.

Sourceval bg_blend_overlay : t

bg_blend_overlay uses overlay background blending.

Sourceval bg_blend_darken : t

bg_blend_darken uses darken background blending.

Sourceval bg_blend_lighten : t

bg_blend_lighten uses lighten background blending.

Sourceval bg_blend_color_dodge : t

bg_blend_color_dodge uses color-dodge background blending.

Sourceval bg_blend_color_burn : t

bg_blend_color_burn uses color-burn background blending.

Sourceval bg_blend_hard_light : t

bg_blend_hard_light uses hard-light background blending.

Sourceval bg_blend_soft_light : t

bg_blend_soft_light uses soft-light background blending.

Sourceval bg_blend_difference : t

bg_blend_difference uses difference background blending.

Sourceval bg_blend_exclusion : t

bg_blend_exclusion uses exclusion background blending.

Sourceval bg_blend_hue : t

bg_blend_hue uses hue background blending.

Sourceval bg_blend_saturation : t

bg_blend_saturation uses saturation background blending.

Sourceval bg_blend_color : t

bg_blend_color uses color background blending.

Sourceval bg_blend_luminosity : t

bg_blend_luminosity uses luminosity background blending.

Mask Clip

Sourceval mask_clip_border : t

mask_clip_border sets mask-clip: border-box.

Sourceval mask_clip_padding : t

mask_clip_padding sets mask-clip: padding-box.

Sourceval mask_clip_content : t

mask_clip_content sets mask-clip: content-box.

Sourceval mask_clip_fill : t

mask_clip_fill sets mask-clip: fill-box.

Sourceval mask_clip_stroke : t

mask_clip_stroke sets mask-clip: stroke-box.

Sourceval mask_clip_view : t

mask_clip_view sets mask-clip: view-box.

Sourceval mask_no_clip : t

mask_no_clip sets mask-clip: no-clip.

Mask Composite

Sourceval mask_add : t

mask_add sets mask-composite: add.

Sourceval mask_subtract : t

mask_subtract sets mask-composite: subtract.

Sourceval mask_intersect : t

mask_intersect sets mask-composite: intersect.

Sourceval mask_exclude : t

mask_exclude sets mask-composite: exclude.

Mask Image

Sourceval mask_none : t

mask_none sets mask-image: none.

Mask Mode

Sourceval mask_alpha : t

mask_alpha sets mask-mode: alpha.

Sourceval mask_luminance : t

mask_luminance sets mask-mode: luminance.

Sourceval mask_match : t

mask_match sets mask-mode: match-source.

Mask Origin

Sourceval mask_origin_border : t

mask_origin_border sets mask-origin: border-box.

Sourceval mask_origin_padding : t

mask_origin_padding sets mask-origin: padding-box.

Sourceval mask_origin_content : t

mask_origin_content sets mask-origin: content-box.

Sourceval mask_origin_fill : t

mask_origin_fill sets mask-origin: fill-box.

Sourceval mask_origin_stroke : t

mask_origin_stroke sets mask-origin: stroke-box.

Sourceval mask_origin_view : t

mask_origin_view sets mask-origin: view-box.

Mask Position

Sourceval mask_center : t

mask_center sets mask-position: center.

Sourceval mask_top : t

mask_top sets mask-position: center top.

Sourceval mask_top_left : t

mask_top_left sets mask-position: 0 0.

Sourceval mask_top_right : t

mask_top_right sets mask-position: 100% 0.

Sourceval mask_bottom : t

mask_bottom sets mask-position: center bottom.

Sourceval mask_bottom_left : t

mask_bottom_left sets mask-position: 0 100%.

Sourceval mask_bottom_right : t

mask_bottom_right sets mask-position: 100% 100%.

Sourceval mask_left : t

mask_left sets mask-position: 0.

Sourceval mask_right : t

mask_right sets mask-position: 100%.

Mask Repeat

Sourceval mask_repeat : t

mask_repeat sets mask-repeat: repeat.

Sourceval mask_no_repeat : t

mask_no_repeat sets mask-repeat: no-repeat.

Sourceval mask_repeat_x : t

mask_repeat_x sets mask-repeat: repeat-x.

Sourceval mask_repeat_y : t

mask_repeat_y sets mask-repeat: repeat-y.

Sourceval mask_repeat_round : t

mask_repeat_round sets mask-repeat: round.

Sourceval mask_repeat_space : t

mask_repeat_space sets mask-repeat: space.

Mask Size

Sourceval mask_auto : t

mask_auto sets mask-size: auto.

Sourceval mask_cover : t

mask_cover sets mask-size: cover.

Sourceval mask_contain : t

mask_contain sets mask-size: contain.

Mask Type

Sourceval mask_type_alpha : t

mask_type_alpha sets mask-type: alpha.

Sourceval mask_type_luminance : t

mask_type_luminance sets mask-type: luminance.

Filters

Filter

Sourceval brightness : int -> t

brightness n sets brightness filter (0-200, where 100 is normal).

Sourceval contrast : int -> t

contrast n sets contrast filter (0-200, where 100 is normal).

Sourceval blur_none : t

blur_none applies no blur.

Sourceval blur_xs : t

blur_xs applies an extra small blur (2px).

Sourceval blur_sm : t

blur_sm applies a small blur (4px).

Sourceval blur : t

blur applies the default blur (8px). Same as blur_md.

Sourceval blur_md : t

blur_md applies a medium blur (12px).

Sourceval blur_lg : t

blur_lg applies a large blur (16px).

Sourceval blur_xl : t

blur_xl applies an extra large blur (24px).

Sourceval blur_2xl : t

blur_2xl applies a 2× large blur (40px).

Sourceval blur_3xl : t

blur_3xl applies a 3× large blur (64px).

Sourceval grayscale : int -> t

grayscale n sets the grayscale filter (0-100).

Sourceval saturate : int -> t

saturate n sets the saturation filter (0-200, where 100 is normal).

Sourceval sepia : int -> t

sepia n sets the sepia filter (0-100).

Sourceval invert : int -> t

invert n sets the invert filter (0-100).

Sourceval hue_rotate : int -> t

hue_rotate n rotates the hue by n degrees.

Backdrop Filter

Sourceval backdrop_brightness : int -> t

backdrop_brightness n applies brightness filter to content behind element. Values: 0-200, where 100 is normal. Useful for frosted glass effects.

Example:

let frosted_overlay =
  to_classes
    [
      backdrop_brightness 75;
      backdrop_saturate 150;
      bg ~shade:100 white;
      opacity 30;
    ]
Sourceval backdrop_contrast : int -> t

backdrop_contrast n sets backdrop contrast filter (0-200, where 100 is normal).

Sourceval backdrop_opacity : float -> t

backdrop_opacity n sets backdrop opacity filter (0-100).

Sourceval backdrop_saturate : int -> t

backdrop_saturate n sets backdrop saturation filter (0-200, where 100 is normal).

Sourceval backdrop_blur_none : t

backdrop_blur_none applies no backdrop blur.

Sourceval backdrop_blur_xs : t

backdrop_blur_xs applies an extra small backdrop blur (2px).

Sourceval backdrop_blur_sm : t

backdrop_blur_sm applies a small backdrop blur (4px).

Sourceval backdrop_blur : t

backdrop_blur applies the default backdrop blur (8px). Same as backdrop_blur_md.

Sourceval backdrop_blur_md : t

backdrop_blur_md applies a medium backdrop blur (12px).

Sourceval backdrop_blur_lg : t

backdrop_blur_lg applies a large backdrop blur (16px).

Sourceval backdrop_blur_xl : t

backdrop_blur_xl applies an extra large backdrop blur (24px).

Sourceval backdrop_blur_2xl : t

backdrop_blur_2xl applies a 2× large backdrop blur (40px).

Sourceval backdrop_blur_3xl : t

backdrop_blur_3xl applies a 3× large backdrop blur (64px).

Tables

Border Collapse

Sourceval border_collapse : t

border_collapse collapses table borders.

Sourceval border_separate : t

border_separate separates table borders.

Border Spacing

Sourceval border_spacing : int -> t

border_spacing n sets border spacing using spacing scale. n is the spacing multiplier (e.g., 4 for border-spacing-4).

Sourceval border_spacing' : float -> t

border_spacing' n is border_spacing for a half-step scale value (e.g. border_spacing' 0.5 for border-spacing-0.5).

Table Layout

Sourceval table_auto : t

table_auto uses automatic table layout.

Sourceval table_fixed : t

table_fixed uses fixed table layout.

Caption Side

Sourceval caption_top : t

caption_top sets caption-side: top.

Sourceval caption_bottom : t

caption_bottom sets caption-side: bottom.

Transitions & Animations

Transition Property

Sourceval transition_none : t

transition_none enables no transition.

Sourceval transition : t

transition enables transitions for common properties (colors, opacity, shadow, transform).

Sourceval transition_all : t

transition_all transitions all properties.

Sourceval transition_colors : t

transition_colors smoothly animates color changes (background, text, border). Essential for hover effects to feel polished.

Example:

let button =
  to_classes [ bg blue; transition_colors; hover [ bg ~shade:700 blue ] ]

Duration is 150ms by default.

Sourceval transition_opacity : t

transition_opacity transitions opacity.

Sourceval transition_shadow : t

transition_shadow transitions box shadow.

Sourceval transition_transform : t

transition_transform transitions transform.

Transition Behavior

Sourceval transition_behavior_normal : t

transition_behavior_normal uses normal transition behavior (default).

Sourceval transition_behavior_allow_discrete : t

transition_behavior_allow_discrete allows discrete transitions where supported. Useful for toggling properties like visibility in a discrete manner.

Transition Duration

Sourceval duration : int -> t

duration n sets transition duration in milliseconds.

Transition Timing Function

Sourceval ease_linear : t

ease_linear uses a linear transition timing function.

Sourceval ease_in : t

ease_in uses an ease-in transition timing function.

Sourceval ease_out : t

ease_out uses an ease-out transition timing function.

Sourceval ease_in_out : t

ease_in_out uses an ease-in-out transition timing function.

Transition Delay

Sourceval delay : int -> t

delay ms sets transition/animation delay in milliseconds.

Transforms

Backface Visibility

Sourceval backface_visible : t

backface_visible shows the element's back face when rotated (default).

Sourceval backface_hidden : t

backface_hidden hides the element's back face when rotated.

Perspective

Sourceval perspective_none : t

perspective_none removes perspective (perspective: none).

Sourceval perspective_dramatic : t

perspective_dramatic sets a short perspective distance for dramatic 3D effects.

Sourceval perspective_normal : t

perspective_normal sets a normal perspective distance.

Perspective Origin

Sourceval perspective_origin_center : t

perspective_origin_center sets perspective origin to center (default).

Sourceval perspective_origin_top : t

perspective_origin_top sets perspective origin to top, making 3D transforms appear from above.

Sourceval perspective_origin_bottom : t

perspective_origin_bottom sets perspective origin to bottom, making 3D transforms appear from below.

Sourceval perspective_origin_left : t

perspective_origin_left sets perspective origin to left side.

Sourceval perspective_origin_right : t

perspective_origin_right sets perspective origin to right side.

Rotate

Sourceval rotate : int -> t

rotate n sets rotate transformation (degrees).

Scale

Sourceval scale : int -> t

scale n resizes element by percentage (100 = normal size).

Examples:

  • scale 95: Slightly smaller (95%)
  • scale 100: Normal size
  • scale 105: Slightly larger (105%) - nice for hover effects
  • scale 150: 1.5x larger

Often combined with transition_transform for smooth scaling.

Skew

Sourceval skew_x : int -> t

skew_x n adds skewX(n deg) to the transform chain.

Sourceval skew_y : int -> t

skew_y n adds skewY(n deg) to the transform chain.

Transform

Sourceval transform : t

transform enables transform utilities.

Sourceval transform_none : t

transform_none disables transforms.

Sourceval transform_gpu : t

transform_gpu uses GPU acceleration for transforms.

Transform Origin

Sourceval origin_center : t

origin_center sets transform-origin: center.

Sourceval origin_top : t

origin_top sets transform-origin: top.

Sourceval origin_bottom : t

origin_bottom sets transform-origin: bottom.

Sourceval origin_left : t

origin_left sets transform-origin: left.

Sourceval origin_right : t

origin_right sets transform-origin: right.

Sourceval origin_top_left : t

origin_top_left sets transform-origin: top left.

Sourceval origin_top_right : t

origin_top_right sets transform-origin: top right.

Sourceval origin_bottom_left : t

origin_bottom_left sets transform-origin: bottom left.

Sourceval origin_bottom_right : t

origin_bottom_right sets transform-origin: bottom right.

Transform Style

Translate

Sourceval translate_x : int -> t

translate_x n sets horizontal translation.

Sourceval translate_x' : float -> t

translate_x' n is translate_x for a half-step scale value (e.g. translate_x' 0.5 for translate-x-0.5).

Sourceval translate_y : int -> t

translate_y n sets vertical translation.

Sourceval translate_y' : float -> t

translate_y' n is translate_y for a half-step scale value.

Sourceval neg_translate_x_1_2 : t

neg_translate_x_1_2 translates the element -50% horizontally (for centering).

Sourceval neg_translate_y_1_2 : t

neg_translate_y_1_2 translates the element -50% vertically (for centering).

Sourceval rotate_x : int -> t

rotate_x n rotates element around X-axis by n degrees. Positive values tilt element away from viewer at top.

Sourceval rotate_y : int -> t

rotate_y n rotates element around Y-axis by n degrees. Positive values rotate element clockwise when viewed from above.

Sourceval rotate_z : int -> t

rotate_z n rotates element around Z-axis by n degrees. Equivalent to regular rotate, positive values rotate clockwise.

Sourceval translate_z : int -> t

translate_z n moves element along Z-axis (toward/away from viewer). Positive values move element closer, negative values move it away.

Sourceval translate_z' : float -> t

translate_z' n is translate_z for a half-step scale value.

Sourceval scale_z : int -> t

scale_z n scales element along Z-axis for 3D effects. Requires transform-style: preserve-3d on parent.

Sourceval transform_style_3d : t

transform_style_3d preserves 3D positioning of child elements. Required for nested 3D transforms.

Sourceval transform_style_flat : t

transform_style_flat flattens child elements into the parent's plane (default).

Container Query Utilities

Container queries allow elements to respond to their container's size rather than the viewport. Inspired by modern CSS capabilities.

Sourceval container : t

container creates a responsive layout container (equivalent to .container in Tailwind v4). Sets width: 100%. Note: Responsive max-width at various breakpoints not yet implemented.

Sourceval at_container : t

at_container enables container queries based on inline-size (equivalent to @container in Tailwind v4). Sets container-type: inline-size.

Sourceval at_container_normal : t

at_container_normal disables container queries (equivalent to @container-normal in Tailwind v4). Sets container-type: normal.

Sourceval at_container_named : string -> t

at_container_named name creates a named container (equivalent to @container/name in Tailwind v4). Sets container-type: inline-size and container-name: name.

Sourceval container_sm : t list -> t

container_sm styles applies styles when container is ≥640px wide.

Sourceval container_md : t list -> t

container_md styles applies styles when container is ≥768px wide.

Sourceval container_lg : t list -> t

container_lg styles applies styles when container is ≥1024px wide.

Sourceval container_xl : t list -> t

container_xl styles applies styles when container is ≥1280px wide.

Sourceval container_2xl : t list -> t

container_2xl styles applies styles when container is ≥1536px wide.

Sourceval container_query : ?name:string -> int -> t list -> t

container_query 500 styles applies styles when container is ≥500px. container_query ~name:"sidebar" 500 styles targets a named container.

Sourceval animate_none : t

animate_none applies no animation.

Sourceval animate_spin : t

animate_spin spins the element 360° continuously. Perfect for loading spinners.

Sourceval animate_ping : t

animate_ping scales and fades out like a radar ping. Great for notification badges or attention-grabbing indicators.

Sourceval animate_pulse : t

animate_pulse gently fades in and out. Useful for skeleton screens or loading placeholders.

Sourceval animate_bounce : t

animate_bounce makes the element bounce up and down. Good for scroll indicators or playful UI elements.

Forms

Sourceval form_input : t

form_input provides base styles for input elements; resets browser defaults and provides consistent styling across browsers. Use with input elements.

Sourceval form_textarea : t

form_textarea provides base styles for textarea elements; ensures consistent cross-browser appearance and behavior.

Sourceval form_select : t

form_select provides base styles for select dropdowns; normalizes appearance across browsers while maintaining native functionality.

Sourceval form_multiselect : t

form_multiselect provides base styles for multi-select lists (select with multiple); matches the input styling without the dropdown chevron.

Sourceval form_checkbox : t

form_checkbox provides base styles for checkbox inputs; enables custom styling while maintaining accessibility.

Sourceval form_radio : t

form_radio provides base styles for radio inputs; enables custom styling while maintaining accessibility.

Interactivity & Scroll

Accent Color

Sourceval accent : ?opacity:int -> ?shade:int -> color -> t

accent color sets the accent color for form controls like checkboxes and radio buttons. shade defaults to 500. opacity sets the alpha modifier (0-100).

Sourceval accent_current : t

accent_current sets accent color to currentColor.

Sourceval accent_inherit : t

accent_inherit sets accent color to inherit.

Caret Color

Sourceval caret : ?opacity:int -> ?shade:int -> color -> t

caret color sets the caret color. shade defaults to 500. opacity sets the alpha modifier (0-100).

Sourceval caret_current : t

caret_current sets caret color to currentColor.

Sourceval caret_inherit : t

caret_inherit sets caret color to inherit.

Sourceval caret_transparent : t

caret_transparent sets caret color to transparent.

Color Scheme

Sourceval scheme_normal : t

scheme_normal sets color-scheme: normal.

Sourceval scheme_light : t

scheme_light sets color-scheme: light.

Sourceval scheme_dark : t

scheme_dark sets color-scheme: dark.

Sourceval scheme_light_dark : t

scheme_light_dark sets color-scheme: light dark.

Sourceval scheme_only_light : t

scheme_only_light sets color-scheme: only light.

Sourceval scheme_only_dark : t

scheme_only_dark sets color-scheme: only dark.

Cursor

Sourceval cursor_auto : t

cursor_auto uses the automatic cursor.

Sourceval cursor_default : t

cursor_default uses the default cursor.

Sourceval cursor_pointer : t

cursor_pointer uses the pointer cursor.

Sourceval cursor_wait : t

cursor_wait uses the wait cursor.

Sourceval cursor_move : t

cursor_move uses the move cursor.

Sourceval cursor_not_allowed : t

cursor_not_allowed uses the not-allowed cursor.

Field Sizing

Sourceval field_sizing_content : t

field_sizing_content sets field-sizing: content.

Sourceval field_sizing_fixed : t

field_sizing_fixed sets field-sizing: fixed.

User Select

Sourceval select_none : t

select_none disables text selection.

Sourceval select_text : t

select_text enables text selection.

Sourceval select_all : t

select_all selects all text on focus.

Sourceval select_auto : t

select_auto uses automatic text selection.

Pointer Events

Sourceval pointer_events_none : t

pointer_events_none disables pointer events.

Sourceval pointer_events_auto : t

pointer_events_auto enables pointer events.

Scroll Snap Type

Sourceval snap_none : t

snap_none disables scroll snapping.

Sourceval snap_x : t

snap_x enables horizontal scroll snapping for carousel-like interfaces. Must be used with snap_start/center/end on children.

Example:

let carousel = to_classes [ flex; overflow_x_auto; snap_x; snap_mandatory ]
let slide = to_classes [ snap_center; flex_shrink_0; w_full ]
Sourceval snap_y : t

snap_y enables vertical scroll snapping. Similar to snap_x but for vertical scrolling.

Sourceval snap_both : t

snap_both enables both horizontal and vertical scroll snapping.

Sourceval snap_mandatory : t

snap_mandatory enforces mandatory scroll snapping.

Sourceval snap_proximity : t

snap_proximity enables proximity-based scroll snapping.

Scroll Snap Align

Sourceval snap_start : t

snap_start snaps to the start of the container.

Sourceval snap_end : t

snap_end snaps to the end of the container.

Sourceval snap_center : t

snap_center snaps to the center of the container.

Sourceval snap_align_none : t

snap_align_none disables snap alignment.

Scroll Snap Stop

Sourceval snap_normal : t

snap_normal uses normal snap stop behavior.

Sourceval snap_always : t

snap_always always stops at snap positions.

Scroll Behavior

Sourceval scroll_auto : t

scroll_auto uses auto scroll behavior.

Sourceval scroll_smooth : t

scroll_smooth uses smooth scroll behavior.

Touch Action

Sourceval touch_auto : t

touch_auto sets touch-action to auto.

Sourceval touch_none : t

touch_none disables touch gestures.

Sourceval touch_manipulation : t

touch_manipulation enables panning and pinch zoom gestures.

Sourceval touch_pan_x : t

touch_pan_x enables horizontal panning.

Sourceval touch_pan_y : t

touch_pan_y enables vertical panning.

Sourceval touch_pan_left : t

touch_pan_left enables left panning.

Sourceval touch_pan_right : t

touch_pan_right enables right panning.

Sourceval touch_pan_up : t

touch_pan_up enables upward panning.

Sourceval touch_pan_down : t

touch_pan_down enables downward panning.

Sourceval touch_pinch_zoom : t

touch_pinch_zoom enables pinch-to-zoom gesture.

Divide

Sourceval divide_x : int -> t

divide_x n sets the border width between horizontal children, in pixels: divide_x 2 is divide-x-2.

Sourceval divide_y : int -> t

divide_y n sets the border width between vertical children.

Sourceval divide_x_length : Cascade.Css.border_width -> t

divide_x_length w is divide_x with an arbitrary width, as divide-x-[3px].

  • raises Invalid_argument

    if w is a keyword or a CSS function, which has no spelling inside a class name.

Sourceval divide_y_length : Cascade.Css.border_width -> t

divide_y_length w is divide_y with an arbitrary width.

  • raises Invalid_argument

    if w is a keyword or a CSS function, which has no spelling inside a class name.

Sourceval divide_x_reverse : t

divide_x_reverse reverses horizontal divide borders for RTL layouts.

Sourceval divide_y_reverse : t

divide_y_reverse reverses vertical divide borders.

Sourceval divide_color : ?opacity:int -> ?shade:int -> color -> t

divide_color color sets the colour of the dividing borders. shade defaults to 500; opacity is the alpha modifier (0-100).

Sourceval divide_transparent : t

divide_transparent makes the dividing borders transparent.

Sourceval divide_current : t

divide_current takes the dividing border colour from currentColor.

Sourceval divide_inherit : t

divide_inherit inherits the dividing border colour.

Sourceval divide_style : Cascade.Css.border_style -> t

divide_style s sets the style of the dividing borders, as divide-dashed.

Scroll Margin

Sourceval scroll_m : int -> t

scroll_m n sets scroll-margin to n spacing units (negative allowed).

Sourceval scroll_m' : float -> t

scroll_m' n is scroll_m for a half-step scale value (e.g. scroll_m' 0.5 for scroll-m-0.5).

Sourceval scroll_mx : int -> t

scroll_mx n sets scroll-margin-inline to n spacing units.

Sourceval scroll_mx' : float -> t

scroll_mx' n is scroll_mx for a half-step scale value.

Sourceval scroll_my : int -> t

scroll_my n sets scroll-margin-block to n spacing units.

Sourceval scroll_my' : float -> t

scroll_my' n is scroll_my for a half-step scale value.

Sourceval scroll_mt : int -> t

scroll_mt n sets scroll-margin-top to n spacing units.

Sourceval scroll_mt' : float -> t

scroll_mt' n is scroll_mt for a half-step scale value.

Sourceval scroll_mr : int -> t

scroll_mr n sets scroll-margin-right to n spacing units.

Sourceval scroll_mr' : float -> t

scroll_mr' n is scroll_mr for a half-step scale value.

Sourceval scroll_mb : int -> t

scroll_mb n sets scroll-margin-bottom to n spacing units.

Sourceval scroll_mb' : float -> t

scroll_mb' n is scroll_mb for a half-step scale value.

Sourceval scroll_ml : int -> t

scroll_ml n sets scroll-margin-left to n spacing units.

Sourceval scroll_ml' : float -> t

scroll_ml' n is scroll_ml for a half-step scale value.

Sourceval scroll_ms : int -> t

scroll_ms n sets scroll-margin-inline-start to n spacing units.

Sourceval scroll_ms' : float -> t

scroll_ms' n is scroll_ms for a half-step scale value.

Sourceval scroll_me : int -> t

scroll_me n sets scroll-margin-inline-end to n spacing units.

Sourceval scroll_me' : float -> t

scroll_me' n is scroll_me for a half-step scale value.

Sourceval scroll_mbs : int -> t

scroll_mbs n sets scroll-margin-block-start to n spacing units.

Sourceval scroll_mbs' : float -> t

scroll_mbs' n is scroll_mbs for a half-step scale value.

Sourceval scroll_mbe : int -> t

scroll_mbe n sets scroll-margin-block-end to n spacing units.

Sourceval scroll_mbe' : float -> t

scroll_mbe' n is scroll_mbe for a half-step scale value.

Scroll Padding

Sourceval scroll_p : int -> t

scroll_p n sets scroll-padding to n spacing units.

Sourceval scroll_p' : float -> t

scroll_p' n is scroll_p for a half-step scale value.

Sourceval scroll_px : int -> t

scroll_px n sets scroll-padding-inline to n spacing units.

Sourceval scroll_px' : float -> t

scroll_px' n is scroll_px for a half-step scale value.

Sourceval scroll_py : int -> t

scroll_py n sets scroll-padding-block to n spacing units.

Sourceval scroll_py' : float -> t

scroll_py' n is scroll_py for a half-step scale value.

Sourceval scroll_pt : int -> t

scroll_pt n sets scroll-padding-top to n spacing units.

Sourceval scroll_pt' : float -> t

scroll_pt' n is scroll_pt for a half-step scale value.

Sourceval scroll_pr : int -> t

scroll_pr n sets scroll-padding-right to n spacing units.

Sourceval scroll_pr' : float -> t

scroll_pr' n is scroll_pr for a half-step scale value.

Sourceval scroll_pb : int -> t

scroll_pb n sets scroll-padding-bottom to n spacing units.

Sourceval scroll_pb' : float -> t

scroll_pb' n is scroll_pb for a half-step scale value.

Sourceval scroll_pl : int -> t

scroll_pl n sets scroll-padding-left to n spacing units.

Sourceval scroll_pl' : float -> t

scroll_pl' n is scroll_pl for a half-step scale value.

Sourceval scroll_ps : int -> t

scroll_ps n sets scroll-padding-inline-start to n spacing units.

Sourceval scroll_ps' : float -> t

scroll_ps' n is scroll_ps for a half-step scale value.

Sourceval scroll_pe : int -> t

scroll_pe n sets scroll-padding-inline-end to n spacing units.

Sourceval scroll_pe' : float -> t

scroll_pe' n is scroll_pe for a half-step scale value.

Sourceval scroll_pbs : int -> t

scroll_pbs n sets scroll-padding-block-start to n spacing units.

Sourceval scroll_pbs' : float -> t

scroll_pbs' n is scroll_pbs for a half-step scale value.

Sourceval scroll_pbe : int -> t

scroll_pbe n sets scroll-padding-block-end to n spacing units.

Sourceval scroll_pbe' : float -> t

scroll_pbe' n is scroll_pbe for a half-step scale value.

Appearance

Sourceval appearance_none : t

appearance_none removes default browser styling from form elements.

Resize

Sourceval resize_none : t

resize_none prevents textarea resizing.

Sourceval resize_y : t

resize_y allows vertical resizing only.

Sourceval resize_x : t

resize_x allows horizontal resizing only.

Sourceval resize : t

resize allows both horizontal and vertical resizing.

Will Change

Sourceval will_change_auto : t

will_change_auto sets will-change to auto.

Sourceval will_change_scroll : t

will_change_scroll optimizes for scroll position changes.

Sourceval will_change_contents : t

will_change_contents optimizes for content changes.

Sourceval will_change_transform : t

will_change_transform optimizes for transform changes.

SVG

Fill

Fill utilities are available in the Svg module.

Stroke

Stroke utilities are available in the Svg module.

Stroke Width

Stroke width utilities are available in the Svg module.

Accessibility

Forced Color Adjust

Accessibility utilities (e.g., sr-only) are available above.

Sourceval sr_only : t

sr_only Screen reader only; visually hides content while keeping it accessible.

Sourceval not_sr_only : t

not_sr_only reverses sr_only; it makes previously screen-reader-only content visible.

Prose Typography

The prose classes provide beautiful typographic defaults for long-form content like articles, blog posts, or documentation. They automatically style headings, paragraphs, lists, code blocks, and more.

Sourceval prose : t

prose applies default prose styling for article-like content. Automatically styles h1–h6, p, ul, ol, blockquote, code, and more.

Example:

let article = to_classes [ prose; prose_lg; max_w_none ]
Sourceval prose_sm : t

prose_sm applies small prose styling (0.875rem base font).

Sourceval prose_lg : t

prose_lg applies large prose styling (1.125rem base font).

Sourceval prose_xl : t

prose_xl applies extra large prose styling (1.25rem base font).

Sourceval prose_2xl : t

prose_2xl applies 2× large prose styling (1.5rem base font).

Sourceval prose_lead : t

prose_lead applies lead paragraph styling for prose.

Sourceval prose_gray : t

prose_gray uses the gray prose color theme.

Sourceval prose_slate : t

prose_slate uses the slate prose color theme.

Sourceval prose_zinc : t

prose_zinc uses the zinc prose color theme.

Sourceval prose_neutral : t

prose_neutral uses the neutral prose color theme.

Sourceval prose_stone : t

prose_stone uses the stone prose color theme.

Sourceval prose_invert : t

prose_invert remaps the prose palette to its inverted (dark) variant.

Sourceval prose_orange : t

prose_orange uses the orange accent (link) prose color theme.

Prose markers

Convenience utilities to apply marker classes used by prose selectors.

Sourceval not_prose : t

not_prose marks a subtree to be excluded from prose styling. Alias of Prose.not_prose.

Class Generation & Internals

Sourceval to_classes : t list -> string

to_classes styles converts your style list to a CSS class string. This is the main function you'll use with HTML elements.

Example:

let button_styles = [ bg blue; text white; px 4; py 2 ]
let button_class = to_classes button_styles
Sourceval pp : t -> string

pp style generates a class name from a style.

Sourceval of_string : ?theme:Scheme.t -> string -> (t, [ `Msg of string ]) result

of_string ?theme class_str parses a Tailwind class string into a style. theme (default Scheme.default) is consulted to validate custom tokens such as named colors and opacities defined in an @theme block.

Example:

let parsed = of_string "bg-blue-500"
let spacing = of_string "p-4"
let centered = of_string "text-center"
let invalid = of_string "unknown-class"

Returns Error (`Msg reason) if the class string is not recognized.

Sourceval split_whitespace : string -> string list

split_whitespace s splits a class attribute into its class names on any HTML whitespace - space, tab, newline, carriage return or form feed - and drops empty runs. This is the split str performs, exposed so that a consumer parsing each name itself, such as Tw_html, agrees with it on what a class name is.

Example:

let names = split_whitespace "flex\n  items-center"
Sourceval of_classes : ?theme:Scheme.t -> string -> t list * string list

of_classes s parses a whitespace-separated string of class names into the utilities it recognised and, in source order, the names it did not. It never raises.

A name that is no utility may be a typo or a deliberate non-tw class - a framework hook, a JS selector, a third-party widget - and parsing cannot tell the two apart, so it reports both and leaves the judgement to the caller. The Tw_html and Tw_dom renderers pass such a name through to the rendered class attribute and report it the same way.

Example:

let styles, unknown = of_classes "flex my-app-header"
Sourceval str : string -> t list

str s is the utilities of of_classes s, dropping the names it did not recognise. Use of_classes to see them.

Example:

let classes = str "flex items-center gap-4 p-6 bg-white rounded-lg"

CSS Generation

This library generates Tailwind-like class names using to_classes.

Important: Class tracking and CSS file generation should be handled by the library user. For example, the Tw_html module collects all used Tw classes and generates the appropriate CSS file.

For dynamic styles that change at runtime, use to_inline_style to generate CSS properties directly for the style attribute.

Sourceval to_inline_style : ?theme:Scheme.t -> t list -> string

to_inline_style ?theme styles generates inline CSS for the style attribute.

Note: This generates only the CSS properties for the given styles, without any Tailwind reset/prelude. The reset is only included in to_css since it's meant for complete stylesheets, not individual elements.

Perfect for tweaking individual HTML nodes with custom styles:

let inline_styles =
  to_inline_style [ bg ~shade:100 blue; p 4; rounded_md; text white ]

When to use to_inline_style vs to_css:

Use to_inline_style when:

  • You need dynamic styles that change at runtime
  • You want to override specific styles on individual elements
  • You're working with existing HTML that you can't modify classes for
  • You need precise control over a single element's styling

Use to_css (preferred) when:

  • You want to generate a stylesheet that can be cached and reused
  • You're building a full website with consistent styling
  • You want better performance (CSS classes are more efficient than inline styles)

Performance considerations: Inline styles are significantly less performant for large-scale use compared to stylesheets because:

  • They increase HTML payload size (styles are repeated for each element)
  • They cannot be cached by the browser like external stylesheets
  • They have higher CSS specificity, making them harder to override
  • They don't benefit from CSS compression and minification

Use to_inline_style sparingly for dynamic or element-specific styling only.

Sourcemodule Css = Cascade.Css

CSS generation utilities

Sourcemodule Prose : sig ... end

Simple prose utilities

Sourcemodule Color : sig ... end

Color conversion utilities for Tailwind v4 compatibility

Sourcemodule Modifiers : sig ... end

Tailwind variant helpers (hover, focus, dark, responsive, group/peer, etc.)

Sourcemodule Var : sig ... end

CSS variable tracking and generation

Sourceval theme_token_rename : theme:Scheme.t -> (string -> string) option

theme_token_rename ~theme is the custom-property rename a prefix(tw) project needs when serialising its sheet, and None when the project asked for no prefix. Pass it to Css.to_string as ?rename_custom_property.

Sourceval property_fallbacks : Css.statement list -> Css.statement list

property_fallbacks rules is the \@layer properties block that gives the \@property rules among rules their initial values in a browser without \@property, under the guard the generated sheet uses for its own: a non-inheriting property on every element, an inheriting one on the root, initial where a rule names no value, and the first rule of a name winning. It is empty when rules holds no \@property.

Sourceval to_css : ?theme:Scheme.t -> ?base:bool -> ?forms:bool -> ?layers:bool -> ?extra:(string * (int * int) * Css.statement list) list -> t list -> Css.t

to_css ?theme ?base ?forms ?layers styles generates a CSS stylesheet for the given styles. theme (default Scheme.default) supplies the theme values utilities read while generating CSS.

The generated CSS follows Tailwind's layering and ordering conventions:

1. Layer Order:

  • base: resets, preflight styles, and semantic element defaults
  • components: component classes (e.g., container or plugin-provided)
  • utilities: atomic utility classes (p-4, bg-red-500, etc.)

2. Utility Ordering (within utilities layer): Utilities are sorted by category in the following order:

  • Layout: position, display, float, clear, isolation, object-fit, overflow, overscroll
  • Flexbox & Grid: flex properties, grid properties, gap, order, place-content/items/self
  • Spacing: padding, margin, space-between
  • Sizing: width, height, min/max dimensions
  • Typography: font-family, font-size, font-weight, letter-spacing, line-height, text properties
  • Backgrounds: background-color, background-image, gradients
  • Borders: border-width, border-color, border-radius, border-style
  • Effects: box-shadow, opacity, mix-blend-mode
  • Filters: filter, backdrop-filter, blur, brightness, contrast
  • Tables: border-collapse, border-spacing, table-layout
  • Transitions & Animation: transition, duration, timing, delay, animation
  • Transforms: scale, rotate, translate, skew
  • Interactivity: cursor, user-select, resize, scroll-behavior
  • SVG: fill, stroke
  • Accessibility: sr-only, not-sr-only

Within each category, utilities maintain a stable order. Variants (hover:, sm:, etc.) are applied with responsive breakpoints in ascending order (sm → md → lg → xl → 2xl) and state modifiers in Tailwind's predetermined priority order.

Rendering choices such as variable inlining, minification, and optimization are handled by Css.to_string.

  • parameter base

    Include base (Preflight) styles (default: true)

  • parameter forms

    Include forms plugin base styles. When true, adds base styles for native HTML form elements. When not specified, auto-detects based on utility classes (form-input, etc.)

  • parameter layers

    Wrap generated rules in Tailwind cascade layers.

Use this to generate your main stylesheet for inclusion in HTML <head>.

Sourceval clip_polygon : (float * float) list -> t

clip_polygon points clips element to a polygon defined by percentage points.

Example:

let triangular_badge =
  to_classes
    [ clip_polygon [ (50., 0.); (0., 100.); (100., 100.) ]; bg red ]

Modifiers

Tailwind variants like hover/focus, responsive breakpoints, dark mode, group/peer, and pseudo-elements.

State Variants

Sourceval hover : t list -> t

hover styles applies styles on :hover.

Sourceval focus : t list -> t

focus styles applies styles on :focus.

Sourceval active : t list -> t

active styles applies styles on :active.

Sourceval disabled : t list -> t

disabled styles applies styles on :disabled.

Sourceval focus_within : t list -> t

focus_within styles applies styles when any descendant has focus.

Sourceval focus_visible : t list -> t

focus_visible styles applies styles when focus is visible.

Group/Peer Variants

Sourceval group : t

group marks an element as a group parent.

Sourceval peer : t

peer marks an element as a peer for sibling selectors.

Sourceval group_hover : t list -> t

group_hover styles applies styles when .group:hover matches.

Sourceval group_focus : t list -> t

group_focus styles applies styles when .group:focus matches.

Sourceval peer_hover : t list -> t

peer_hover styles applies styles when a preceding .peer:hover matches.

Sourceval peer_focus : t list -> t

peer_focus styles applies styles when a preceding .peer:focus matches.

Sourceval has : string -> t list -> t

has selector styles applies styles with :has(selector).

Sourceval group_has : ?name:string -> string -> t list -> t

group_has ?name selector styles applies styles under .group:has(selector).

Sourceval peer_has : ?name:string -> string -> t list -> t

peer_has ?name selector styles applies styles when a preceding .peer:has(selector).

Theme/Motion/Contrast

Sourceval dark : t list -> t

dark styles applies styles when user prefers dark mode, or under the rules of Scheme.t.dark when the theme the CSS is generated with redeclares the variant.

Sourceval motion_safe : t list -> t

motion_safe styles applies styles when reduced motion is not requested.

Sourceval motion_reduce : t list -> t

motion_reduce styles applies styles when reduced motion is requested.

Sourceval contrast_more : t list -> t

contrast_more styles applies styles when higher contrast is preferred.

Sourceval contrast_less : t list -> t

contrast_less styles applies styles when lower contrast is preferred.

Sourceval starting : t list -> t

starting styles applies styles using @starting-style.

Responsive Breakpoints

Sourceval sm : t list -> t

sm styles applies styles at small breakpoint.

Sourceval md : t list -> t

md styles applies styles at medium breakpoint.

Sourceval lg : t list -> t

lg styles applies styles at large breakpoint.

Sourceval xl : t list -> t

xl styles applies styles at extra-large breakpoint.

Sourceval xl2 : t list -> t

xl2 styles applies styles at 2xl breakpoint.

Pseudo-elements

Sourceval before : t list -> t

before styles applies styles to ::before. Combine with content utilities.

Sourceval after : t list -> t

after styles applies styles to ::after. Combine with content utilities.

ARIA Variants

Sourceval aria_checked : t list -> t

aria_checked styles applies styles when aria-checked=true.

Sourceval aria_expanded : t list -> t

aria_expanded styles applies styles when aria-expanded=true.

Sourceval aria_selected : t list -> t

aria_selected styles applies styles when aria-selected=true.

Sourceval aria_disabled : t list -> t

aria_disabled styles applies styles when aria-disabled=true.

Data Attributes

Sourceval data_state : string -> t -> t

data_state value style applies style when data-state=value.

Sourceval data_variant : string -> t -> t

data_variant value style applies style when data-variant=value.

Sourceval data_custom : string -> string -> t -> t

data_custom key value style applies style when data-key=value.

Sourceval data_active : t list -> t

data_active styles applies styles when data-active is present.

Sourceval data_inactive : t list -> t

data_inactive styles applies styles when data-inactive is present.

Sourceval peer_checked : t list -> t

peer_checked styles applies styles when a preceding .peer:checked.

Prose Element Variants

These target specific HTML elements within prose content. Each variant wraps the utility in a descendant selector that targets the specified element(s), excluding elements inside .not-prose.

Sourceval prose_headings : t list -> t

prose_headings styles applies styles to h1-h6, th within prose.

Sourceval prose_p : t list -> t

prose_p styles applies styles to p elements within prose.

Sourceval prose_a : t list -> t

prose_a styles applies styles to a elements within prose.

Sourceval prose_strong : t list -> t

prose_strong styles applies styles to strong elements within prose.

Sourceval prose_em : t list -> t

prose_em styles applies styles to em elements within prose.

Sourceval prose_code : t list -> t

prose_code styles applies styles to code elements within prose.

Sourceval prose_pre : t list -> t

prose_pre styles applies styles to pre elements within prose.

Sourceval prose_ol : t list -> t

prose_ol styles applies styles to ol elements within prose.

Sourceval prose_ul : t list -> t

prose_ul styles applies styles to ul elements within prose.

Sourceval prose_li : t list -> t

prose_li styles applies styles to li elements within prose.

Sourceval prose_blockquote : t list -> t

prose_blockquote styles applies styles to blockquote elements within prose.

Sourceval prose_h1 : t list -> t

prose_h1 styles applies styles to h1 elements within prose.

Sourceval prose_h2 : t list -> t

prose_h2 styles applies styles to h2 elements within prose.

Sourceval prose_h3 : t list -> t

prose_h3 styles applies styles to h3 elements within prose.

Sourceval prose_h4 : t list -> t

prose_h4 styles applies styles to h4 elements within prose.

Sourceval prose_h5 : t list -> t

prose_h5 styles applies styles to h5 elements within prose.

Sourceval prose_h6 : t list -> t

prose_h6 styles applies styles to h6 elements within prose.

Sourceval prose_dl : t list -> t

prose_dl styles applies styles to dl elements within prose.

Sourceval prose_dt : t list -> t

prose_dt styles applies styles to dt elements within prose.

Sourceval prose_dd : t list -> t

prose_dd styles applies styles to dd elements within prose.

Sourceval prose_table : t list -> t

prose_table styles applies styles to table elements within prose.

Sourceval prose_tr : t list -> t

prose_tr styles applies styles to tr elements within prose.

Sourceval prose_picture : t list -> t

prose_picture styles applies styles to picture elements within prose.

Sourceval prose_img : t list -> t

prose_img styles applies styles to img elements within prose.

Sourceval prose_video : t list -> t

prose_video styles applies styles to video elements within prose.

Sourceval prose_figure : t list -> t

prose_figure styles applies styles to figure elements within prose.

Sourceval prose_figcaption : t list -> t

prose_figcaption styles applies styles to figcaption elements within prose.

Sourceval prose_hr : t list -> t

prose_hr styles applies styles to hr elements within prose.

Sourceval prose_th : t list -> t

prose_th styles applies styles to th elements within prose.

Sourceval prose_td : t list -> t

prose_td styles applies styles to td elements within prose.

Sourceval prose_thead : t list -> t

prose_thead styles applies styles to thead elements within prose.

Sourceval prose_kbd : t list -> t

prose_kbd styles applies styles to kbd elements within prose.

Sourcemodule Style : sig ... end

Core types and helpers for Tailwind CSS DSL

Sourcemodule Margin : sig ... end

Margin utilities with negative value support

Sourcemodule Padding : sig ... end

Padding utilities

Sourcemodule Gap : sig ... end

Gap and space-between utilities

Sourcemodule Flex : sig ... end

Flexbox display utilities (flex, inline-flex).

Sourcemodule Flex_props : sig ... end

Flexbox property utilities (grow, shrink, basis, order, flex shortcuts).

Sourcemodule Flex_layout : sig ... end

Flexbox layout utilities (direction, wrap).

Sourcemodule Alignment : sig ... end

Alignment utilities for flexbox and grid layouts

Sourcemodule Borders : sig ... end

Border utilities for border styles, widths, and radii

Sourcemodule Backgrounds : sig ... end

Background and gradient utilities

Sourcemodule Sizing : sig ... end

Sizing utilities for width and height

Sourcemodule Layout : sig ... end

Layout utilities for display, positioning, and z-index

Sourcemodule Overflow : sig ... end

Overflow utilities

Sourcemodule Typography : sig ... end

Typography utilities for text and font styling

Sourcemodule Grid : sig ... end

Grid display utilities (grid, inline-grid).

Sourcemodule Grid_item : sig ... end

Grid item placement utilities (col-n, row-n).

Sourcemodule Grid_template : sig ... end

Grid template utilities for grid layout configuration

Sourcemodule Divide : sig ... end

Divide utilities for creating gaps between child elements

Sourcemodule Effects : sig ... end

Visual effects utilities for shadows, opacity, and filters

Sourcemodule Transforms : sig ... end

Transform utilities for 2D and 3D transformations

Sourcemodule Interactivity : sig ... end

Interactivity utilities for selection, scroll behavior, and more

Sourcemodule Containers : sig ... end

Container query utilities for responsive design based on container size

Sourcemodule Filters : sig ... end

Filter utilities for visual effects like blur, brightness, and backdrop filters

Sourcemodule Position : sig ... end

Position utilities for controlling element placement

Sourcemodule Animations : sig ... end

Animation utilities

Sourcemodule Transitions : sig ... end

Transition utilities

Sourcemodule Forms : sig ... end

Form element utilities - matching Tailwind v4's \@tailwindcss/forms plugin.

Sourcemodule Tables : sig ... end

Table-related utilities

Sourcemodule Svg : sig ... end

SVG utilities for fill, stroke, and stroke-width

Sourcemodule Accessibility : sig ... end

Accessibility utilities

Sourcemodule Output : sig ... end

CSS rule output — the result of extracting a Tailwind utility class.

Sourcemodule Build : sig ... end

CSS layer assembly — converts Output.t lists into Tailwind's layered stylesheet.

Sourcemodule Theme : sig ... end

Shared theme variables for consistent ordering and avoiding conflicts

Sourcemodule Scheme : sig ... end

Theme scheme configuration for customizing CSS output.

Sourcemodule Utility : sig ... end

Utility module for common utility types and functions

Sourcemodule Spacing : sig ... end

Shared spacing utilities for padding, margin, and gap

Sourcemodule Box_sizing : sig ... end

Box sizing utilities

Sourcemodule Tab : sig ... end

tab-size utilities.

Sourcemodule Scrollbar : sig ... end

Scrollbar utilities: scrollbar-width, scrollbar-gutter, scrollbar-thumb, and scrollbar-track.

Sourcemodule Zoom : sig ... end

zoom utilities (the zoom-* scale).

Sourcemodule Columns : sig ... end

Columns utilities for multi-column layout

Sourcemodule Contain : sig ... end

Contain utilities for CSS containment.

Sourcemodule Field_sizing : sig ... end

Field sizing utilities

Sourcemodule Mask_gradient : sig ... end

Mask gradient utilities

Sourcemodule Masks : sig ... end

Mask utilities for CSS masking

Sourcemodule Overflow_wrap : sig ... end

Overflow wrap utilities

Sourcemodule Overscroll : sig ... end

Overscroll behavior utilities

Sourcemodule Scroll : sig ... end

Scroll margin and padding utilities

Sourcemodule Text_shadow : sig ... end

Text shadow utilities

Sourcemodule Touch : sig ... end

Touch-action utilities

Sourcemodule Arbitrary : sig ... end

Arbitrary property utilities: [property:value] with optional /opacity.

Sourcemodule Property : sig ... end

Helpers for building the @layer properties block.

Sourcemodule Parse : sig ... end

Parsing helpers for small integers and results.