### Initialize and Install Project Dependencies (Bash) Source: https://github.com/ihiutch/uswds-tailwind/blob/next/apps/docs/src/content/pages/getting-started.mdx This snippet covers initializing a new project directory and installing essential dependencies for USWDS and Tailwind CSS, including Tailwind itself and various icon and font packages. It's a foundational step for setting up the project environment. ```bash mkdir my-project && cd my-project npm init -y npm i @uswds-tailwind/compat @uswds-tailwind/theme npm i tailwindcss @tailwindcss/vite @iconify-json/fa-solid @iconify-json/fa6-brands @iconify-json/material-symbols npm i @fontsource-variable/open-sans @fontsource-variable/public-sans @fontsource-variable/roboto-mono @fontsource-variable/source-sans-3 @fontsource-variable/merriweather ``` -------------------------------- ### Create Project Structure (Bash) Source: https://github.com/ihiutch/uswds-tailwind/blob/next/apps/docs/src/content/pages/getting-started.mdx This command creates the necessary directories and files for a standard project structure, including source, assets, JavaScript, and CSS folders, along with an index.html file and a .gitignore file. This sets up the basic organization for your project. ```bash mkdir {src,src/assets,src/assets/js,src/assets/css} touch src/index.html src/assets/js/main.js src/assets/css/styles.css .gitignore ``` -------------------------------- ### Tailwind CSS Grid Column Offset Example Source: https://github.com/ihiutch/uswds-tailwind/blob/next/apps/docs/src/content/components/grid.mdx Illustrates how to create column offsets in a Tailwind CSS grid layout using 'col-start' and 'col-span' utilities. This example positions a column starting from the 5th column and spanning 8 columns. ```html
1
2
3
4
5
6
7
8
9
10
11
12
(col-span-1)
.col-start-5.col-span-8
``` -------------------------------- ### Install USWDS Tailwind Packages and Fonts Source: https://context7.com/ihiutch/uswds-tailwind/llms.txt Installs the core theme and compatibility packages for USWDS Tailwind, along with required Google Fonts. This is the initial setup step for using the library. ```bash # Install packages npm install @uswds-tailwind/theme @uswds-tailwind/compat # Install required fonts npm install @fontsource-variable/open-sans @fontsource-variable/public-sans \ @fontsource-variable/roboto-mono @fontsource-variable/source-sans-3 \ @fontsource-variable/merriweather ``` -------------------------------- ### Run Astro Development Server (Bash) Source: https://github.com/ihiutch/uswds-tailwind/blob/next/README.md Command to start the Astro development server for the USWDS Tailwind project. This allows for local development and previewing of the documentation site. Assumes project dependencies are already installed. ```bash pnpm dev ``` -------------------------------- ### Tailwind CSS Grid Gutters Example Source: https://github.com/ihiutch/uswds-tailwind/blob/next/apps/docs/src/content/components/grid.mdx Demonstrates how to use Tailwind CSS utility classes to define gutters and column spans within a 12-column grid system. This example shows varying gap sizes between columns. ```html
1
2
3
4
5
6
7
8
9
10
11
12
(col-span-1)
(col-span-1)
(col-span-1)
(col-span-1)
(col-span-1)
(col-span-1)
``` -------------------------------- ### Clone Repository and Install Dependencies (Bash) Source: https://github.com/ihiutch/uswds-tailwind/blob/next/README.md This snippet shows how to clone the USWDS Tailwind repository and install its dependencies using PNPM. It is essential for setting up the development environment. Ensure Node.js (v18+) and PNPM are installed beforehand. ```bash git clone https://github.com/IHIutch/uswds-tailwind.git cd uswds-tailwind pnpm install pnpm build ``` -------------------------------- ### Icon List Simple Content Example Source: https://github.com/ihiutch/uswds-tailwind/blob/next/apps/docs/src/content/components/icon-list.mdx This example demonstrates an icon list for presenting simple content, like program benefits. It utilizes thumb-up icons and Tailwind CSS for a clean, list-based layout. ```html

Benefits of joining Global Entry program:

``` -------------------------------- ### Sticky Column Table Example (HTML) Source: https://github.com/ihiutch/uswds-tailwind/blob/next/apps/docs/src/content/components/table.mdx Illustrates how to create a table with sticky columns using USWDS and Tailwind CSS. This example focuses on making the first column ('Document title') sticky on the left, improving navigation in wide tables. It includes styling for borders and active sort states. ```html
Bordered table
Document title Description Year
Declaration of Independence Statement adopted by the Continental Congress declaring independence from the British Empire. 1776
Bill of Rights The first ten amendments of the U.S. Constitution guaranteeing rights and freedoms. 1791
Declaration of Sentiments A document written during the Seneca Falls Convention outlining the rights that American women should be entitled to as citizens. 1848
Emancipation Proclamation An executive order granting freedom to slaves in designated southern states. 1863
``` -------------------------------- ### HTML Structure for USWDS + Tailwind Project (HTML) Source: https://github.com/ihiutch/uswds-tailwind/blob/next/apps/docs/src/content/pages/getting-started.mdx This HTML snippet provides a basic structure for an index.html file, including meta tags, title, linking the main stylesheet, and setting up a body with USWDS-specific classes for layout and a sample button. It also includes a script tag to load the main JavaScript file. ```html USWDS + Tailwind

Welcome to USWDS + Tailwind!

``` -------------------------------- ### USWDS Tailwind Grid Layout Examples (HTML) Source: https://github.com/ihiutch/uswds-tailwind/blob/next/apps/docs/src/content/components/grid.mdx Demonstrates the usage of the USWDS Tailwind grid system for creating flexible page layouts. This example showcases a 12-column base, custom column spans, and responsive adjustments for tablet viewports. ```html
1
2
3
4
5
6
7
8
9
10
11
12
(col-span-1)
(col-span-1)
(col-span-1)
(col-span-1)
(col-span-1)
(col-span-1)
.col-span-4
.col-span-4
.col-span-4
.tablet:col-span-4
.tablet:col-span-4
.tablet:col-span-4
``` -------------------------------- ### Tooltip Example with Tailwind CSS Source: https://github.com/ihiutch/uswds-tailwind/blob/next/apps/docs/src/content/components/tooltip.mdx This snippet demonstrates the implementation of a tooltip component using Tailwind CSS classes. It includes examples for tooltips positioned at the top, right, bottom, and left. The component requires a JavaScript plugin for full functionality, which is noted in the documentation. ```html
Top
Right
Bottom
Left
``` -------------------------------- ### Run Development Server for Theme Package Source: https://github.com/ihiutch/uswds-tailwind/blob/next/packages/theme/README.md Starts a local development server for the theme package. This command is used during development to preview changes and test the theme. Refer to package.json for other available scripts. ```bash npm run dev ``` -------------------------------- ### Date Picker Component Example in HTML Source: https://github.com/ihiutch/uswds-tailwind/blob/next/apps/docs/src/content/components/date-range-picker.mdx This HTML snippet defines a date range picker component. It includes input fields for the start and end dates, along with buttons to trigger the calendar view. The component uses data-part attributes for element identification and Tailwind CSS for styling, providing a visually appealing and interactive date selection interface. ```html
mm/dd/yyyy
mm/dd/yyyy
``` -------------------------------- ### Create and Navigate Project Directory Source: https://github.com/ihiutch/uswds-tailwind/blob/next/examples/vanilla-ts/typography.html This snippet demonstrates how to create a new project directory and initialize a Node.js project within it using npm. It's a common starting point for many web development projects. ```bash mkdir my-project && cd my-project npm init -y ``` -------------------------------- ### Configure JavaScript for USWDS Components (JavaScript) Source: https://github.com/ihiutch/uswds-tailwind/blob/next/apps/docs/src/content/pages/getting-started.mdx This JavaScript snippet shows two methods for initializing USWDS components using the '@uswds-tailwind/compat' package. It covers both auto-initialization of all components and manual initialization of specific components like modals and accordions after the DOM is loaded. ```javascript // Option 1: Auto-initialize all components import '@uswds-tailwind/compat/auto' // Option 2: Manual initialization with only the components you need import { modalInit, accordionInit } from '@uswds-tailwind/compat' document.addEventListener('DOMContentLoaded', () => { modalInit() accordionInit() }) ``` -------------------------------- ### Configure CSS with USWDS Theme and Fonts (CSS) Source: https://github.com/ihiutch/uswds-tailwind/blob/next/apps/docs/src/content/pages/getting-started.mdx This CSS snippet configures the project's main stylesheet by importing various Google Fonts, Tailwind CSS, and the USWDS Tailwind theme. It ensures that all necessary styles and typography are loaded correctly for the application. ```css /* Only import the fonts you need! */ @import "@fontsource-variable/open-sans"; @import "@fontsource-variable/public-sans"; @import "@fontsource-variable/roboto-mono"; @import "@fontsource-variable/source-sans-3"; @import "@fontsource-variable/merriweather"; @import "tailwindcss"; @import "@uswds-tailwind/theme"; ``` -------------------------------- ### Vue Integration: Declarative Accordion Component Source: https://context7.com/ihiutch/uswds-tailwind/llms.txt Demonstrates integrating USWDS Tailwind Accordion components within a Vue.js application using the declarative data-attribute API. This example utilizes Vue's `onMounted` and `onUnmounted` lifecycle hooks for Accordion instance management, ensuring proper setup and cleanup. ```vue ``` -------------------------------- ### Configure .gitignore for Project (Shell) Source: https://github.com/ihiutch/uswds-tailwind/blob/next/apps/docs/src/content/pages/getting-started.mdx This shell snippet defines a .gitignore file to prevent unnecessary files and directories, such as node_modules, Parcel cache, and build outputs, from being committed to version control. It's crucial for maintaining a clean repository, with a specific note about the 'build' directory if manual compilation is performed. ```shell node_modules .parcel-cache build ``` -------------------------------- ### Date Picker Day Button Styling (HTML) Source: https://github.com/ihiutch/uswds-tailwind/blob/next/apps/docs/src/content/components/date-range-picker.mdx This HTML snippet defines the styling for individual day buttons within the date picker. It includes classes for hover effects, focus states, range selection (start, end, in-range), and disabled states, ensuring clear visual feedback for users. ```html ``` -------------------------------- ### Input Mask Component with Examples (HTML) Source: https://github.com/ihiutch/uswds-tailwind/blob/next/apps/docs/src/content/components/input-mask.mdx This HTML component showcases input masks for various formats like SSN, phone numbers, ZIP codes, and alphanumeric strings. It utilizes Tailwind CSS for styling and custom data attributes for functionality. The input elements have specific patterns and placeholders to guide user input. ```html
For example, 123 45 6789
For example, (123) 456-7890
For example, 12345-6789
For example, A1B 2C3
``` -------------------------------- ### Responsive Grid Layouts with Tailwind CSS Source: https://github.com/ihiutch/uswds-tailwind/blob/next/apps/docs/src/content/components/grid.mdx Demonstrates a responsive 12-column grid system using Tailwind CSS utility classes. The layouts adapt based on viewport size, utilizing classes like `grid-cols-12` and `tablet:col-span-*`. This code snippet showcases how to create flexible and responsive interfaces that adjust to different screen dimensions. ```html
1
2
3
4
5
6
7
8
9
10
11
12
(col-span-1)
.col-span-2
.col-span-3
.col-span-4
.col-span-2
.tablet:col-span-8
.tablet:col-span-2
.tablet:col-span-2
.tablet:col-span-8
.col-span-6.tablet:col-span-4
.col-span-6.tablet:col-span-4
.col-span-6.tablet:col-span-4
.col-span-6.tablet:col-span-4
.col-span-6
.col-span-6
``` -------------------------------- ### Illustrating 12-Column Layout with Tailwind CSS Grid Source: https://github.com/ihiutch/uswds-tailwind/blob/next/apps/docs/src/content/components/grid.mdx This code snippet visualizes a 12-column grid system using Tailwind CSS. It's useful for understanding the foundational structure of responsive layouts. No external dependencies are required beyond Tailwind CSS. ```html
1
2
3
4
5
6
7
8
9
10
11
12
``` -------------------------------- ### Install Tailwind Theme Package with npm Source: https://github.com/ihiutch/uswds-tailwind/blob/next/packages/theme/README.md Installs the theme package using npm. Replace '@your-org' with the correct organization scope. This is the primary method for integrating the theme into projects. ```bash npm install @your-org/theme ``` -------------------------------- ### HTML List Component Example Source: https://github.com/ihiutch/uswds-tailwind/blob/next/apps/docs/src/content/components/list.mdx This snippet demonstrates the implementation of a List component using HTML, styled with USWDS and Tailwind CSS. It includes examples of unordered, ordered, and unstyled list variations. ```html
  • Unordered list item
  • Unordered list item
  • Unordered list item
  1. Ordered list item
  2. Ordered list item
  3. Ordered list item
  • Unstyled list item
  • Unstyled list item
  • Unstyled list item
```