Position
Position (Pos
for short) lets you place elements at the cardinal points in a Stack
or Relative
container.
-->
Position (Pos
for short) lets you place elements at the cardinal points in a Stack
or Relative
container.
Just pick a position and place your element. No need to overthink or dive into CSS positioning complexities.
Just add full
to the Pos
class and you’ll get it.
Pos
lets you nudge
an element towards the center. While nudging, Pos
also calculates the perfect border radius without work on your part!
Pos
must be used in a Stack
or Relative
container. If you use Tailwind, relative
works too.
To use Pos
, just choose one of the directional classes and apply it to the element.
There are four top
positions.
Pos-topleft
: Place content at the top left cornerPos-top
: Place content at the topPos-topright
: Place content at the top right cornerPos-topfull
: Place content at the top, spanning the full widthThere are four bottom
positions.
Pos-bottomleft
: Place content at the bottom left cornerPos-bottom
: Place content at the bottomPos-bottomright
: Place content at the bottom right cornerPos-bottomfull
: Place content at the bottom, spanning the full widthThere are two left
positions.
Pos-left
: Place content at the leftPos-leftfull
: Place content at the left, spanning the full heightThere are two right
positions.
Pos-right
: Place content at the rightPos-rightfull
: Place content at the right, spanning the full heightYou can center an element with Pos-center
.
Although you can create an overlay with Pos-overlay
, you’re essentially stacking more elements on top of each other. So we would recommending just adding another element in Stack
instead.
The only time you need Pos-overlay
is if the container is Relative
.
You can nudge elements towards the center with --nudge
. This is useful for creating elements that are slightly away from the edge of the Stack
or Relative
container.
When you use nudge
, Pos
automatically calulates the border-radius
of your nudged element according to the border radius formula.
For this to work, you need to specify your outer border radius with --radius
. (You may also need to create a border for the wrapping element).
The border radius formula may not produce the best results in all circumstances. For example nudge
may produce a nested border radius of 0 if the nudge
value is larger than --radius
.
Inner Border radius is 0. Not very nice.
Top left
Top right
Bottom left
Bottom right
In these circumstances, it may be better to specify a custom border radius for the nudged element instead. To do this, you will need to increase the specificity of your border radius declaration to at least [0,2,0] (2 classes).
If you use Tailwind, you can achieve this additional specificity by adding the !important
modifier with !
.
Splendid Labz is free because we love developers and we want to contribute back to the ecosystem.
We only charge for access to the documentation to keep the project going. If you don't wish to pay, feel free to use the content from the features tab, our blogs or our videos as your guide.
Pos
must be used in a Stack
or Relative
container. If you use Tailwind, relative
works too.
To use Pos
, just choose one of the directional classes and apply it to the element.
There are four top
positions.
Pos-topleft
: Place content at the top left cornerPos-top
: Place content at the topPos-topright
: Place content at the top right cornerPos-topfull
: Place content at the top, spanning the full widthThere are four bottom
positions.
Pos-bottomleft
: Place content at the bottom left cornerPos-bottom
: Place content at the bottomPos-bottomright
: Place content at the bottom right cornerPos-bottomfull
: Place content at the bottom, spanning the full widthThere are two left
positions.
Pos-left
: Place content at the leftPos-leftfull
: Place content at the left, spanning the full heightThere are two right
positions.
Pos-right
: Place content at the rightPos-rightfull
: Place content at the right, spanning the full heightYou can center an element with Pos-center
.
Although you can create an overlay with Pos-overlay
, you’re essentially stacking more elements on top of each other. So we would recommending just adding another element in Stack
instead.
The only time you need Pos-overlay
is if the container is Relative
.
You can nudge elements towards the center with --nudge
. This is useful for creating elements that are slightly away from the edge of the Stack
or Relative
container.
When you use nudge
, Pos
automatically calulates the border-radius
of your nudged element according to the border radius formula.
For this to work, you need to specify your outer border radius with --radius
. (You may also need to create a border for the wrapping element).
The border radius formula may not produce the best results in all circumstances. For example nudge
may produce a nested border radius of 0 if the nudge
value is larger than --radius
.
Inner Border radius is 0. Not very nice.
Top left
Top right
Bottom left
Bottom right
In these circumstances, it may be better to specify a custom border radius for the nudged element instead. To do this, you will need to increase the specificity of your border radius declaration to at least [0,2,0] (2 classes).
If you use Tailwind, you can achieve this additional specificity by adding the !important
modifier with !
.
The CSS for Pos
can be pretty complex because we supported both Stack
and Relative
for many positions.
Splendid Labz is free because we love developers and we want to contribute back to the ecosystem.
We only charge for access to the documentation to keep the project going. If you don't wish to pay, feel free to use the content from the features tab, our blogs or our videos as your guide.
The CSS for Pos
can be pretty complex because we supported both Stack
and Relative
for many positions.
Class | Description |
---|---|
Pos-topleft | Place content at the top left corner |
Pos-top | Place content at the top |
Pos-topright | Place content at the top right corner |
Pos-topfull | Place content at the top, spanning the full width |
Pos-left | Place content at the left |
Pos-bottomleft | Place content at the bottom left corner |
Pos-bottom | Place content at the bottom |
Pos-bottomright | Place content at the bottom right corner |
Pos-bottomfull | Place content at the bottom, spanning the full width |
Pos-leftfull | Place content at the left, spanning the full height |
Pos-right | Place content at the right |
Pos-rightfull | Place content at the right, spanning the full height |
Pos-center | Place content at the center. |
Pos-overlay | Creates an overlay. |
Variable | Default | Description |
---|---|---|
--nudge | 0 | Amount to push towards the center on both block and inline axis |
--nudge-x | 0 | Amount to push towards the center on the inline axis |
--nudge-y | 0 | Amount to push towards the center on the block axis |
Variable | Default | Description |
---|---|---|
--radius | 0.5rem | Outer border radius to use for the inner border radius calculation |
Splendid Labz is free because we love developers and we want to contribute back to the ecosystem.
We only charge for access to the documentation to keep the project going. If you don't wish to pay, feel free to use the content from the features tab, our blogs or our videos as your guide.
Class | Description |
---|---|
Pos-topleft | Place content at the top left corner |
Pos-top | Place content at the top |
Pos-topright | Place content at the top right corner |
Pos-topfull | Place content at the top, spanning the full width |
Pos-left | Place content at the left |
Pos-bottomleft | Place content at the bottom left corner |
Pos-bottom | Place content at the bottom |
Pos-bottomright | Place content at the bottom right corner |
Pos-bottomfull | Place content at the bottom, spanning the full width |
Pos-leftfull | Place content at the left, spanning the full height |
Pos-right | Place content at the right |
Pos-rightfull | Place content at the right, spanning the full height |
Pos-center | Place content at the center. |
Pos-overlay | Creates an overlay. |
Variable | Default | Description |
---|---|---|
--nudge | 0 | Amount to push towards the center on both block and inline axis |
--nudge-x | 0 | Amount to push towards the center on the inline axis |
--nudge-y | 0 | Amount to push towards the center on the block axis |
Variable | Default | Description |
---|---|---|
--radius | 0.5rem | Outer border radius to use for the inner border radius calculation |