consul/ui/packages/consul-ui/docs/hds.mdx

99 lines
3.2 KiB
Plaintext
Raw Normal View History

---
title: Hashicorp Design System
---
# Hashicorp Design System
2022-10-25 12:03:31 +00:00
The application integrates setup that make it possible to use the [Hashicorp Design System (HDS)](https://github.com/hashicorp/design-system) in the application. The application also
bundles [TailwindCSS](https://tailwindcss.com/) to follow a utility-based CSS approach that mixes well with HDS utility classes. Tailwind is expected to be used
as a supplement to HDS's utility classes, and should mainly be used for layouting.
## Design Tokens
### Colors
2022-10-25 12:03:31 +00:00
To make sure we follow HDS-guidelines, we disabled Tailwind's color utilities completely. Instead of relying on Tailwind for colors, you should be working with the colors from HashiCorp-Design-System and follow the [guidance in the docs](https://design-system-components-hashicorp.vercel.app/foundations/colors) on how to use them:
```hbs preview-template
2022-10-25 12:03:31 +00:00
<h2 class='hds-foreground-strong'>
HDS is awesome
</h2>
```
2022-10-25 12:03:31 +00:00
Regular TailwindCSS colors aren't available.
```hbs preview-template
2022-10-25 12:03:31 +00:00
<h2 class='text-red-400'>
TailwindCSS colors won't work
</h2>
```
2022-10-25 12:03:31 +00:00
### HDS tokens
2022-10-25 12:03:31 +00:00
HDS tokens are available via the provided `hds`-[utility-classes](https://design-system-components-hashicorp.vercel.app/foundations/typography) made available via `@hashicorp/design-system-tokens`.
You for example would work with HDS' typography tokens in this way:
```hbs preview-template
2022-10-25 12:03:31 +00:00
<p class='hds-typography-display-400'>
A paragraph styled via HDS.
</p>
```
2022-10-25 12:03:31 +00:00
Because HDS provides utility classes for typography you should not be using Tailwind classes to customize typography.
### Combining HDS and Tailwind
2022-10-25 12:03:31 +00:00
Tailwind is used as a supplement to what HDS provides. You will be using Tailwind for layouting and other utility functionality that isn't provided by HDS.
```hbs preview-template
2022-10-25 12:03:31 +00:00
<button type='button' class='underline transform scale-100 transition ease-in-out hover:scale-125'>
Hover me
</button>
```
### Components
All components from Hashicorp Design System are available for you to use. Here's an example that shows how to implement a navigation bar with HDS and Tailwind in combination.
```hbs preview-template
2022-10-25 12:03:31 +00:00
<nav
class='h-16 w-full bg-[color:var(--token-color-palette-neutral-700)] flex items-center justify-between px-4 hds-font-weight-medium'
>
<ul class='flex items-center'>
<li>
{{! should probably be a context-switcher }}
<FlightIcon
2022-10-25 12:03:31 +00:00
@name='menu'
@color='var(--token-color-foreground-high-contrast)'
class='cursor-pointer'
/>
</li>
<li>
2022-10-25 12:03:31 +00:00
<FlightIcon @name='consul' class='ml-4 h-8 w-8' @color='var(--token-color-consul-brand)' />
</li>
</ul>
2022-10-25 12:03:31 +00:00
<ul class='flex items-center space-x-2'>
<li>
<Hds::Dropdown as |dd|>
2022-10-25 12:03:31 +00:00
<dd.ToggleButton @text='Help' />
<dd.Title @text='Consul HDS' />
<dd.Interactive @text='Documentation' @icon='docs-link' />
<dd.Interactive @text='HashiCorp Learn' @icon='learn-link' />
<dd.Separator />
2022-10-25 12:03:31 +00:00
<dd.Interactive @text='Provide Feedback' @icon='github' />
</Hds::Dropdown>
</li>
<li>
2022-10-25 12:03:31 +00:00
<Hds::Link::Standalone
@href='https://hashicorp.com'
@icon='settings'
@iconPosition='trailing'
@size='medium'
@text='Settings'
/>
</li>
</ul>
</nav>
```