package tw

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Tw.StyleSource

Core types and helpers for Tailwind CSS DSL

Sourcetype breakpoint = [
  1. | `Sm
  2. | `Md
  3. | `Lg
  4. | `Xl
  5. | `Xl_2
]
Sourcetype container_cmp =
  1. | Cq_min
  2. | Cq_max
    (*

    Container-query direction: Cq_min is width >= v, Cq_max is width < v.

    *)
Sourcetype container_query =
  1. | Container_3xs
  2. | Container_2xs
  3. | Container_xs
  4. | Container_sm
  5. | Container_md
  6. | Container_lg
  7. | Container_xl
  8. | Container_2xl
  9. | Container_3xl
  10. | Container_4xl
  11. | Container_5xl
  12. | Container_6xl
  13. | Container_7xl
  14. | Container_named of string * int
  15. | Container_size of container_cmp * container_query
    (*

    @min-<size> / @max-<size>; the inner query is a bare named size.

    *)
  16. | Container_len of Cascade.Css.length
    (*

    @[<len>]: width >= len.

    *)
  17. | Container_len_cmp of container_cmp * Cascade.Css.length
    (*

    @min-[<len>] / @max-[<len>].

    *)
Sourcetype modifier =
  1. | Hover
  2. | Focus
  3. | Active
  4. | Disabled
  5. | Group_hover
  6. | Group_focus
  7. | Dark
  8. | Responsive of breakpoint
  9. | Min_responsive of breakpoint
  10. | Max_responsive of breakpoint
  11. | Min_arbitrary of float
  12. | Max_arbitrary of float
  13. | Min_arbitrary_length of Cascade.Css.length
  14. | Max_arbitrary_length of Cascade.Css.length
  15. | Peer_hover
  16. | Peer_focus
  17. | Peer_checked
  18. | Aria_checked
  19. | Aria_expanded
  20. | Aria_selected
  21. | Aria_disabled
  22. | Data_state of string
  23. | Data_variant of string
  24. | Data_active
  25. | Data_inactive
  26. | Data_custom of string * string
  27. | Container of container_query
  28. | Not of modifier
  29. | Has of string
  30. | Group_has of string * string option
  31. | Peer_has of string * string option
  32. | Starting
  33. | Focus_within
  34. | Focus_visible
  35. | Motion_safe
  36. | Motion_reduce
  37. | Contrast_more
  38. | Contrast_less
  39. | Pseudo_before
  40. | Pseudo_after
  41. | First
  42. | Last
  43. | Only
  44. | Odd
  45. | Even
  46. | First_of_type
  47. | Last_of_type
  48. | Only_of_type
  49. | Nth of string
  50. | Nth_last of string
  51. | Nth_of_type of string
  52. | Nth_last_of_type of string
  53. | Empty
  54. | Checked
  55. | Indeterminate
  56. | Default
  57. | Required
  58. | Valid
  59. | Invalid
  60. | In_range
  61. | Out_of_range
  62. | Placeholder_shown
  63. | Autofill
  64. | Read_only
  65. | Read_write
  66. | Optional
  67. | Open
  68. | Enabled
  69. | Target
  70. | Visited
  71. | Inert
  72. | User_valid
  73. | User_invalid
  74. | Group_first
  75. | Group_last
  76. | Group_only
  77. | Group_odd
  78. | Group_even
  79. | Group_first_of_type
  80. | Group_last_of_type
  81. | Group_only_of_type
  82. | Peer_first
  83. | Peer_last
  84. | Peer_only
  85. | Peer_odd
  86. | Peer_even
  87. | Peer_first_of_type
  88. | Peer_last_of_type
  89. | Peer_only_of_type
  90. | Group_active
  91. | Group_visited
  92. | Group_disabled
  93. | Group_checked
  94. | Group_empty
  95. | Group_required
  96. | Group_valid
  97. | Group_invalid
  98. | Group_indeterminate
  99. | Group_default
  100. | Group_open
  101. | Group_target
  102. | Peer_active
  103. | Peer_visited
  104. | Peer_disabled
  105. | Peer_empty
  106. | Peer_required
  107. | Peer_valid
  108. | Peer_invalid
  109. | Peer_indeterminate
  110. | Peer_default
  111. | Peer_open
  112. | Peer_target
  113. | Group_optional
  114. | Peer_optional
  115. | Group_read_only
  116. | Peer_read_only
  117. | Group_read_write
  118. | Peer_read_write
  119. | Group_inert
  120. | Peer_inert
  121. | Group_user_valid
  122. | Peer_user_valid
  123. | Group_user_invalid
  124. | Peer_user_invalid
  125. | Group_placeholder_shown
  126. | Peer_placeholder_shown
  127. | Group_autofill
  128. | Peer_autofill
  129. | Group_in_range
  130. | Peer_in_range
  131. | Group_out_of_range
  132. | Peer_out_of_range
  133. | Group_focus_within
  134. | Peer_focus_within
  135. | Group_focus_visible
  136. | Peer_focus_visible
  137. | Group_enabled
  138. | Peer_enabled
  139. | Pseudo_marker
  140. | Pseudo_selection
  141. | Pseudo_placeholder
  142. | Pseudo_backdrop
  143. | Pseudo_file
  144. | Pseudo_first_letter
  145. | Pseudo_first_line
  146. | Pseudo_details_content
  147. | Children
  148. | Descendants
  149. | Ltr
  150. | Rtl
  151. | Print
  152. | Portrait
  153. | Landscape
  154. | Forced_colors
  155. | Inverted_colors
  156. | Pointer_none
  157. | Pointer_coarse
  158. | Pointer_fine
  159. | Any_pointer_none
  160. | Any_pointer_coarse
  161. | Any_pointer_fine
  162. | Noscript
  163. | Supports of string
  164. | Group_hocus
  165. | Peer_hocus
  166. | Custom_responsive of string
  167. | Min_custom of string
  168. | Max_custom of string
  169. | Group_arbitrary of string
  170. | Peer_arbitrary of string
  171. | Hocus
    (*

    :hover, :focus compound selector (no media query)

    *)
  172. | Device_hocus
    (*

    :hover, :focus compound + @media (hover: hover)

    *)
  173. | Not_bracket of string
    (*

    not-[...] bracket patterns — stores raw bracket content

    *)
  174. | In_bracket of string
    (*

    in-[...] ancestor patterns — element must be descendant of selector

    *)
  175. | In_data of string
    (*

    in-data-X — element must be descendant of data-X

    *)
  176. | Group_not of modifier * string option
    (*

    group-not-X/name — inner modifier + optional group name

    *)
  177. | Peer_not of modifier * string option
    (*

    peer-not-X/name — inner modifier + optional peer name

    *)
  178. | Data_bracket of string
    (*

    data-[expr] — full CSS attribute expression, e.g. "foo$=bar_baz_i"

    *)
  179. | Group_data of string * string option
    (*

    group-data-[expr]/name — group data variant with optional name

    *)
  180. | Peer_data of string * string option
    (*

    peer-data-[expr]/name — peer data variant with optional name

    *)
  181. | Aria_bracket of string
    (*

    aria-[expr] — arbitrary aria attribute, e.g. "modal", "valuenow=1"

    *)
  182. | Group_aria of string * string option
    (*

    group-aria-X/name — group aria variant with optional name

    *)
  183. | Peer_aria of string * string option
    (*

    peer-aria-X/name — peer aria variant with optional name

    *)
  184. | Not_named_group of modifier * string
    (*

    not-group-X/name — negate named group variant

    *)
  185. | Has_named_group of modifier * string
    (*

    has-group-X/name — has named group variant

    *)
  186. | In_named_group of modifier * string
    (*

    in-group-X/name — descendant of named group variant

    *)
  187. | Group_peer_named of modifier * string
    (*

    group-peer-X/name — peer-X within named group

    *)
  188. | Arbitrary_selector of string
    (*

    [&_p] — arbitrary selector variant

    *)
  189. | Custom_variant of string * string
    (*

    is-data-foo: — a matchVariant-registered variant: the class-name token and the resolved selector template (& is the own class).

    *)
  190. | Container_style of string * Cascade.Css.Container.t
    (*

    has-a: — a @custom-variant whose body is a container query: the class-name token and the structural container condition (so not- can negate it soundly).

    *)
  191. | Prose_element of string
    (*

    prose-X: — prose element variant for targeting specific HTML elements within prose content

    *)
Sourcetype t =
  1. | Style of {
    1. props : Cascade.Css.declaration list;
    2. rules : Cascade.Css.statement list option;
    3. property_rules : Cascade.Css.t;
    4. merge_key : string option;
    5. pseudo_suffix : Cascade.Css.Selector.t option;
    }
  2. | Modified of modifier * t
  3. | Group of t list
Sourceval pp : t -> string

pp t returns a string representation of a style.

Sourcetype size = [
  1. | `None
  2. | `Xs
  3. | `Sm
  4. | `Md
  5. | `Lg
  6. | `Xl
  7. | `Xl_2
  8. | `Xl_3
  9. | `Full
  10. | `Rem of float
]
Sourcetype spacing = [
  1. | `Px
  2. | `Full
  3. | `Rem of float
  4. | `Named of string
]
Sourcetype margin = [
  1. | spacing
  2. | `Auto
]
Sourcetype scale = [
  1. | spacing
  2. | size
  3. | `Screen
  4. | `Min
  5. | `Max
  6. | `Fit
]
Sourcetype max_scale = [
  1. | scale
  2. | `Xl_4
  3. | `Xl_5
  4. | `Xl_6
  5. | `Xl_7
]
Sourcetype shadow = [
  1. | size
  2. | `Inner
]
Sourceval is_numeric : string -> bool

is_numeric s returns true if s is a non-empty string of digits.

Sourceval pp_nth : string -> string -> string

pp_nth prefix expr formats an nth modifier, using numeric or bracket form.

Sourceval pp_modifier : modifier -> string

pp_modifier m converts a modifier to its string representation.

Sourceval container_size_name : container_query -> string

container_size_name q is the class-name suffix (after the leading @) for a container query, e.g. "md", "max-lg", "min-[20rem]".

Sourceval style : ?rules:Cascade.Css.statement list option -> ?property_rules:Cascade.Css.t -> ?merge_key:string -> ?pseudo_suffix:Cascade.Css.Selector.t -> Cascade.Css.declaration list -> t

style ?rules ?property_rules props defines a utility with CSS props.

  • rules: Optional custom CSS rules (for utilities like prose that generate multiple rules with descendant selectors).
  • property_rules: Optional CSS property rules needed by this utility.
  • props: CSS properties to apply.
Sourceval map_important : t -> t

map_important t marks every declaration t emits as !important (the ! utility prefix), recursing through modifiers, groups and nested rules.