From 5713630109ac8c3f2d28d49359f0a6bf4b105a85 Mon Sep 17 00:00:00 2001 From: John Leider Date: Fri, 2 Feb 2024 22:46:45 -0600 Subject: [PATCH] feat(position): add left/top/right/bottom-0 utility classes --- packages/docs/src/data/nav.json | 1 + .../docs/src/examples/position/absolute.vue | 37 +++++++++++ packages/docs/src/examples/position/fixed.vue | 22 +++++++ .../docs/src/examples/position/relative.vue | 11 ++++ .../docs/src/examples/position/static.vue | 11 ++++ .../docs/src/examples/position/sticky.vue | 27 ++++++++ packages/docs/src/pages/en/styles/position.md | 65 +++++++++++++++++++ .../src/styles/settings/_utilities.scss | 20 ++++++ 8 files changed, 194 insertions(+) create mode 100644 packages/docs/src/examples/position/absolute.vue create mode 100644 packages/docs/src/examples/position/fixed.vue create mode 100644 packages/docs/src/examples/position/relative.vue create mode 100644 packages/docs/src/examples/position/static.vue create mode 100644 packages/docs/src/examples/position/sticky.vue create mode 100644 packages/docs/src/pages/en/styles/position.md diff --git a/packages/docs/src/data/nav.json b/packages/docs/src/data/nav.json index fb3f45000a7..3995f4c9142 100644 --- a/packages/docs/src/data/nav.json +++ b/packages/docs/src/data/nav.json @@ -68,6 +68,7 @@ "flex", "float", "overflow", + "position", "sizing", "spacing", "text-and-typography" diff --git a/packages/docs/src/examples/position/absolute.vue b/packages/docs/src/examples/position/absolute.vue new file mode 100644 index 00000000000..d2d036cbbf1 --- /dev/null +++ b/packages/docs/src/examples/position/absolute.vue @@ -0,0 +1,37 @@ + diff --git a/packages/docs/src/examples/position/fixed.vue b/packages/docs/src/examples/position/fixed.vue new file mode 100644 index 00000000000..aaba79e27d7 --- /dev/null +++ b/packages/docs/src/examples/position/fixed.vue @@ -0,0 +1,22 @@ + diff --git a/packages/docs/src/examples/position/relative.vue b/packages/docs/src/examples/position/relative.vue new file mode 100644 index 00000000000..94bc8a77ec5 --- /dev/null +++ b/packages/docs/src/examples/position/relative.vue @@ -0,0 +1,11 @@ + diff --git a/packages/docs/src/examples/position/static.vue b/packages/docs/src/examples/position/static.vue new file mode 100644 index 00000000000..546c4808699 --- /dev/null +++ b/packages/docs/src/examples/position/static.vue @@ -0,0 +1,11 @@ + diff --git a/packages/docs/src/examples/position/sticky.vue b/packages/docs/src/examples/position/sticky.vue new file mode 100644 index 00000000000..da76eeab927 --- /dev/null +++ b/packages/docs/src/examples/position/sticky.vue @@ -0,0 +1,27 @@ + diff --git a/packages/docs/src/pages/en/styles/position.md b/packages/docs/src/pages/en/styles/position.md new file mode 100644 index 00000000000..0cf998c8bb0 --- /dev/null +++ b/packages/docs/src/pages/en/styles/position.md @@ -0,0 +1,65 @@ +--- +emphasized: true +meta: + title: Position + description: Use position utilities to quickly style the positioning of any element. + keywords: position classes, positioning utilities, vuetify position helper classes +related: + - /styles/display/ + - /styles/spacing/ + - /styles/flex/ +--- + +# Position + +Utilities for controlling the positioning of elements in your application. + + + +| Class | Properties | +| - | - | +| **position-static** | position: static; | +| **position-relative** | position: relative; | +| **position-absolute** | position: absolute; | +| **position-fixed** | position: fixed; | +| **position-sticky** | position: sticky; | +| **top-0** | top: 0; | +| **right-0** | right: 0; | +| **bottom-0** | bottom: 0; | +| **left-0** | left: 0; | + + + +## Usage + +The `position` utilities allow you to quickly style the positioning of any element. These classes can be used to apply the `position` and `top`, `right`, `bottom`, and `left` properties to an element. + +### Static + +The default position value for all elements is `static`. This means that the element is positioned according to the normal flow of the document. The `top`, `right`, `bottom`, `left` properties have no effect on a statically positioned element. + + + +### Relative + +The `position-relative` class allows you to position an element relative to its normal position in the document. This means that the `top`, `right`, `bottom`, and `left` properties can be used to move the element from its normal position. + + + +### Absolute + +The `position-absolute` class allows you to position an element relative to its closest positioned ancestor. If no positioned ancestor is found, the element is positioned relative to the document body. + + + +### Fixed + +The `position-fixed` class allows you to position an element relative to the viewport. This means that the element will stay in the same position even when the page is scrolled. + + + +### Sticky + +The `position-sticky` class allows you to position an element based on the user's scroll position. The element is treated as `relative` until it crosses a specified threshold, at which point it is treated as `fixed`. + + diff --git a/packages/vuetify/src/styles/settings/_utilities.scss b/packages/vuetify/src/styles/settings/_utilities.scss index 68569838b02..ae429e8d3da 100644 --- a/packages/vuetify/src/styles/settings/_utilities.scss +++ b/packages/vuetify/src/styles/settings/_utilities.scss @@ -532,6 +532,26 @@ $utilities: () !default; class: position, values: static relative fixed absolute sticky ), + "top": ( + property: top, + class: top, + values: 0 + ), + "right": ( + property: right, + class: right, + values: 0 + ), + "bottom": ( + property: bottom, + class: bottom, + values: 0 + ), + "left": ( + property: left, + class: left, + values: 0 + ), // Cursor "cursor": ( property: cursor,