Css
Stylesheets written in Scala, with Laminar's own typed style props: rules for selectors, holding what an element's inline styles cannot, its states (:hover), its parts (::after), and styles for some media alone (@media), with keyframes and font faces besides.
A rule nested in another applies within it, its & standing for the outer rule's selector (else a descendant of it), as in CSS nesting, but each is written out whole, for any browser:
import com.raquo.laminar.api.L.*
import com.alecdorrington.laminarcomponents.Css.{media, rule}
val styles = Stylesheet(
rule(".card")(
padding.px(12),
borderRadius.px(8),
rule("&:hover")(backgroundColor := "#eef"),
rule(".card-title")(fontWeight.bold),
media("(max-width: 600px)")(padding.px(8)),
),
)
Import the builders by name, as Laminar has a media of its own.
Attributes
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
Css.type
Members list
Type members
Classlikes
A rule, at-rule or nesting of rules, that a stylesheet holds.
A rule, at-rule or nesting of rules, that a stylesheet holds.
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
Rules applying only under a condition, as @media and @supports have, or nested in a rule, declarations for its selector under the condition.
Rules applying only under a condition, as @media and @supports have, or nested in a rule, declarations for its selector under the condition.
Value parameters
- parts
-
The rules, and within a rule, declarations.
- prelude
-
The at-rule's keyword and condition, as
@media (pointer: coarse).
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait Blockclass Objecttrait Matchableclass AnyShow all
A font face.
A font face.
Value parameters
- descriptors
-
Its descriptors, as
fontFamily := "Caveat"andCssProps.fontSource.
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait Blockclass Objecttrait Matchableclass AnyShow all
An animation's keyframes.
An animation's keyframes.
Value parameters
- frames
-
Each keyframe, its selector
from,toor a percentage. - name
-
The animation's name.
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait Blockclass Objecttrait Matchableclass AnyShow all
A rule: declarations for whatever its selector matches, and rules nested in it.
A rule: declarations for whatever its selector matches, and rules nested in it.
Value parameters
- parts
-
The declarations and nested rules, in order.
- selector
-
The selector, or several, separated by commas.
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait Blockclass Objecttrait Matchableclass AnyShow all
Types
A declaration: a style prop set to a value, as top.px(0) sets top.
A declaration: a style prop set to a value, as top.px(0) sets top.
Attributes
What a rule holds: its declarations, and rules nested in it.
What a rule holds: its declarations, and rules nested in it.
Attributes
Value members
Concrete methods
Makes a font face.
Makes a font face.
Value parameters
- descriptors
-
Its descriptors.
Attributes
- Returns
-
The font face.
Makes an animation's keyframes.
Makes an animation's keyframes.
Value parameters
- frames
-
Each keyframe, as
rule("from")(opacity := 0). - name
-
The animation's name.
Attributes
- Returns
-
The keyframes.
Makes rules apply only to the media a query matches.
Makes rules apply only to the media a query matches.
Value parameters
- parts
-
The rules, and nested in a rule, declarations for its selector.
- query
-
The media query, as
(max-width: 600px).
Attributes
- Returns
-
The conditional rules.
Writes blocks out as CSS, every nested rule written out whole.
Writes blocks out as CSS, every nested rule written out whole.
Value parameters
- blocks
-
The blocks, in order.
Attributes
- Returns
-
Their CSS.
Makes a rule.
Makes a rule.
Value parameters
- parts
-
The declarations and nested rules, in order.
- selector
-
The selector, or several, separated by commas; nested,
&stands for the outer rule's selector.
Attributes
- Returns
-
The rule.
Makes rules apply only where the browser supports a feature.
Makes rules apply only where the browser supports a feature.
Value parameters
- condition
-
The condition, as
(field-sizing: content). - parts
-
The rules, and nested in a rule, declarations for its selector.
Attributes
- Returns
-
The conditional rules.