Container3.0
The anchor-container is a component that serves as a generic container for other components or content. It's designed to be flexible and reusable across different parts of an application.
Installation
npm i @tryg/vue-ui-libraryUsage
Install the component library as a Vue plugin. This globally registers all Anchor components.
import { createApp } from 'vue';
import { ComponentLibrary } from '@tryg/vue-ui-library';
import App from './App.vue';
const app = createApp(App);
app.use(ComponentLibrary);
app.mount('#app');<template>
<anchor-container>This is an error message.</anchor-container>
</template>Import only the components you need for optimal bundle size.
<script setup>
import { AnchorContainer } from '@tryg/vue-ui-library';
</script>
<template>
<anchor-container>This is an error message.</anchor-container>
</template>Custom Width
Use the --container-width-max CSS custom property to control the maximum width of the container content. By default, the container constrains content to a predefined maximum width. You can override this to suit your layout needs:
anchor-container {
--container-width-max: 1200px;
}To allow the container to stretch to full width, set the max width to 100%:
anchor-container {
--container-width-max: 100%;
}Custom Margins
Override the horizontal margins per breakpoint using the --container-margin-* CSS custom properties. Each breakpoint has its own variable so you can fine-tune spacing as the viewport changes:
anchor-container {
--container-margin-xs: 8px;
--container-margin-sm: 16px;
--container-margin-md: 24px;
--container-margin-lg: 32px;
--container-margin-xl: 48px;
}CSS variables
The Container component exposes the following CSS custom properties for styling and layout control:
| Name | Description |
|---|---|
--container-width-max | Set the maximum width of the page content. |
--container-margin-xs | Set the margin of the container at the smallest screen size. |
--container-margin-sm | Set the margin of the container at the small screen size. |
--container-margin-md | Set the margin of the container at the medium screen size. |
--container-margin-lg | Set the margin of the container at the large screen size. |
--container-margin-xl | Set the margin of the container at the extra large screen size. |
Accessibility
The Container component is a non-semantic wrapper element. It does not add any ARIA roles, states, or semantic meaning to its content. It serves purely as a layout container for constraining and centering content within the viewport.
API
anchor-container
CSS Custom Properties
| Name | Description |
|---|---|
--container-margin-lg | Set the margin of the container at the large screen size. |
--container-margin-md | Set the margin of the container at the medium screen size. |
--container-margin-sm | Set the margin of the container at the small screen size. |
--container-margin-xl | Set the margin of the container at the extra large screen size. |
--container-margin-xs | Set the margin of the container at the smallest screen size. |
--container-width-max | Set the maximum width of the page content. |
Built with StencilJS
| Anchor version | Status | Notes |
|---|---|---|
| 3.0 | Ready for Implementation | This component is in sync with Figma. |
