The component can be imported via:
The CenterBaseline component can be used to align content (like icons or images)
vertically with text, especially when a center-aligned flex container isn't possible.
The component creates a flex container, which includes a pseudo element containing
a hidden zero-width space. This ensures the element has a baseline that is
consistent with the baseline of text content.
The example below shows a comparison between a plain image, and one using the
CenterBaseline component.
To allow building custom components with the same behavior as CenterBaseline,
we include additional utilities:
The component's style export
is an object which includes:
classNames - an object with keys containing class names
centerBaseline - the main class, which applies the flex and align stylecenterBaselineInline - to be used in addition to the main class,
applies an inline-flex insteadcenterBaselineBefore - this class contains a the ::before pseudo-element
definition for adding the hidden spacerawStyles - an object with more utilities
centerBaselinePseudo - a plain object that contains the styles applied in
the centerBaselineBefore class, which can be used to construct custom
vanilla-extract stylesSprinkles for applying the same styles are also included:
centerBaseline - which accepts the following values:
true/'true' - applies the flex container style, and the pseudo element style'inline' - applies the inline-flex style, and the pseudo element stylecenterBaselineBefore - can be used to only apply the pseudo element (::before)
style on particular elementsPlumaCenterBaseline extends BoxDefault:false
Whether to apply an inline-flex style to the element (instead of the default flex)