button-card
Copilot instructions2.5k starsChanged 8 years agoMITView on GitHub
CRITICAL: Always reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does not match the info here. Button Card is a TypeScript-based custom Lovelace card for Home Assistant. It provides customizable button elements with advanced styling, state management, and interaction capabilities.
We split this copilot-instructions.md into the rules it gives an agent
15 rules. About 1 is common, 4 are distinctive, and 10 are very specific to this project.
≈1
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
10
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Distinctive: line 3
CRITICAL: Always reference these instructions first and fallback to search or bash commands only when you encounter unexpected information …
- Very specific: line 11
Run linting: npm run lint -- takes ~2 seconds
- Distinctive: line 14
NEVER CANCEL: All build commands must complete fully.
- Very specific: line 17
Start development server: npm run watch -- runs on http://localhost:5000
- Very specific: line 23
ALWAYS run npm run lint before committing changes or the CI (.github/workflows/ci.yml) will fail
- Very specific: line 25
ALWAYS build and test your changes: npm run build followed by manual validation
- Very specific: line 76
Run npm run lint to check code style
- Very specific: line 77
Run npm run build to build and test compilation
- Very specific: line 78
Start dev server with npm run watch to test changes
- Distinctive: line 88
NO AUTOMATED TESTS: This project relies on manual testing and linting only
- Very specific: line 89
Test environment: Use files in test/ directory with Home Assistant
- Very specific: line 125
TypeScript errors: Check type definitions in src/types/
- Common: line 126
Import errors: Verify module paths and ensure proper exports
- Very specific: line 127
Dependency issues: Delete node_modules/ and run yarn install --frozen-lockfile
- Distinctive: line 148
Must work within Home Assistant's Lovelace card framework
≈ “Common” is an estimate: at least 1 in 5 of the 3,669 Copilot instructions files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Button Card - GitHub Copilot Development Instructions
CRITICAL: Always reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does not match the info here.
Button Card is a TypeScript-based custom Lovelace card for Home Assistant. It provides customizable button elements with advanced styling, state management, and interaction capabilities.
Working Effectively
Bootstrap and Build
- Install dependencies:
yarn install --frozen-lockfile-- takes 10-60 seconds depending on cache. NEVER CANCEL. Set timeout to 120+ seconds. - Run linting:
npm run lint-- takes ~2 seconds - Build the project:
npm run build-- takes ~7 seconds (includes lint + rollup) - Build only (skip lint):
npm run rollup-- takes ~5 seconds - NEVER CANCEL: All build commands must complete fully. Use timeout values of 120+ seconds for yarn install, 60+ seconds for builds.
Development Workflow
- Start development server:
npm run watch-- runs onhttp://localhost:5000 - The dev server serves the built card at
http://localhost:5000/button-card.js - Changes auto-rebuild and are served immediately
- Access the built card via the development server for testing
Validation and Quality
- ALWAYS run
npm run lintbefore committing changes or the CI (.github/workflows/ci.yml) will fail - Format code:
npx prettier --check src/**/*.ts(check) andnpx prettier --write src/**/*.ts(fix) - ALWAYS build and test your changes:
npm run buildfollowed by manual validation - Security updates:
npm run audit-fix- fixes known security vulnerabilities - CRITICAL VALIDATION: After making changes, ALWAYS test the card functionality by:
- Building the project:
npm run build - Starting the dev server:
npm run watch - Verifying the card loads at
http://localhost:5000/button-card.js - Testing basic card functionality if possible
- Building the project:
Repository Structure
Key Directories
src/- TypeScript source codebutton-card.ts- Main card component (LitElement)types/- TypeScript type definitionscommon/- Shared utilities and helpershelpers.ts- Utility functions for state, color, and entity managementstyles.ts- CSS styling definitionsaction-handler.ts- Event handling for user interactions
dist/- Built output (generated, do not edit)test/- Home Assistant test environment configuration.github/- CI/CD workflows and GitHub configurationexamples/- Example configurations and images
Important Files
package.json- Dependencies and npm scriptsrollup.config.js- Build configuration using Rollup bundlertsconfig.json- TypeScript compiler configuration.eslintrc.js- ESLint linting rules.prettierrc.yaml- Code formatting rulestest/configuration.yaml- Home Assistant test configurationtest/ui-lovelace.yaml- Lovelace dashboard test configuration
Technology Stack
Core Technologies
- TypeScript - Primary language
- Lit (LitElement) - Web components framework for the card UI
- Rollup - Module bundler and build tool
- Home Assistant - Target platform (custom Lovelace card)
- Web Components - Card is implemented as a custom element
Development Tools
- ESLint - Code linting with TypeScript rules
- Prettier - Code formatting
- Yarn - Package management (lockfile: yarn.lock)
- Node.js 22.x - Development environment (as per CI configuration)
Common Development Tasks
Making Code Changes
- Edit TypeScript files in
src/ - Run
npm run lintto check code style - Run
npm run buildto build and test compilation - Start dev server with
npm run watchto test changes - Validate card functionality manually
Adding New Features
- Main card logic: Edit
src/button-card.ts - Type definitions: Add to
src/types/types.tsor related files - Styling: Update
src/styles.ts - Utilities: Add to
src/helpers.tsorsrc/common/
Debugging and Testing
- NO AUTOMATED TESTS: This project relies on manual testing and linting only
- Test environment: Use files in
test/directory with Home Assistant - The test environment includes mock entities and a sample Lovelace configuration
- Manual testing workflow: Build → Start dev server → Test in Home Assistant or browser
Working with Home Assistant Integration
- The card integrates with Home Assistant's Lovelace dashboard system
- Entity management: Use functions in
src/helpers.ts - State handling: Core logic in
src/button-card.ts - Events and actions: Handled by
src/action-handler.ts
Build System Details
Scripts Available
npm run build- Full build (lint + rollup)npm run rollup- Bundle only (no linting)npm run lint- ESLint validationnpm run watch- Development server with auto-rebuildnpm run audit-fix- Fix security vulnerabilities
Build Timing Expectations
- yarn install: 10-60 seconds depending on cache (NEVER CANCEL - use 120+ second timeout)
- npm run lint: ~2 seconds
- npm run build: ~7 seconds (NEVER CANCEL - use 60+ second timeout)
- npm run rollup: ~5 seconds
- npm run watch: Starts in ~5 seconds, then watches for changes
CI/CD Pipeline
- Located in
.github/workflows/ci.yml - Runs on Node.js 22.x
- Performs: yarn install → npm run lint → npm run build
- Uses yarn with frozen lockfile for reproducible builds
Troubleshooting
Common Issues
- Build failures: Usually linting errors - run
npm run lintfirst - TypeScript errors: Check type definitions in
src/types/ - Import errors: Verify module paths and ensure proper exports
- Dependency issues: Delete
node_modules/and runyarn install --frozen-lockfile
Performance Notes
- The built card (
dist/button-card.js) is ~190KB minified with source maps - Build process includes TypeScript compilation, bundling, and minification
- Development server provides fast rebuilds with file watching
- Comments are stripped during the build process for size optimization
Key Considerations
Generated Files (Do Not Edit)
dist/- All files are generated by the build processnode_modules/- Package dependencies (use yarn.lock for reproducible installs)button-card.js.map- Source maps for debugging (generated with builds)
Code Style
- Uses Prettier with specific configuration (single quotes, trailing commas, 120 char width)
- ESLint enforces TypeScript best practices
- Follows Lit/LitElement patterns for web components
Home Assistant Compatibility
- Must work within Home Assistant's Lovelace card framework
- Follows Home Assistant's custom card development patterns
- Integrates with Home Assistant's state management and service calling
Version Management
- Uses semantic-release for automated versioning
- Main branch:
master - Development branch:
dev(open PRs against this) - Supports both stable and beta releases
REMEMBER: NEVER CANCEL long-running commands. Build processes may take several minutes. Always wait for completion and use appropriate timeout values (120+ seconds for installs, 60+ seconds for builds).
Trending
More talk lately.about the whole repository
Who's talking about custom-cards/button-card
- kalkih/mini-media-player“Support action `fire-dom-event`”GitHub · Feb 14, 2021 · 3 reactions
- kalkih/mini-graph-card“Support action `fire-dom-event`”GitHub · Feb 13, 2021 · 3 reactions
- benct/lovelace-multiple-entity-row“Support action `fire-dom-event`”GitHub · Feb 13, 2021 · 2 reactions
- @tom-doerr.bsky.social“https://github.com/custom-cards/button-card”Bluesky · May 9, 2026 · 1 likes
- @chrisraible.com“I've also really enjoyed working with the custom button card github.com/custom-cards..., which offers a lot …”Bluesky · Jan 2, 2025 · 1 likes
The biggest 5 of 25 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 25
Talked about on GitHub and Bluesky (25 times).
On GitHub · 22
- Feb 14, 2021Support action `fire-dom-event` — kalkih/mini-media-player3 reactions · 2 comments
- Feb 13, 2021Support action `fire-dom-event` — kalkih/mini-graph-card3 reactions · 2 comments
- Feb 13, 2021Support action `fire-dom-event` — benct/lovelace-multiple-entity-row2 reactions · 1 comment
- Jun 22, 2022[FR] button-card-like configuration templates — kalkih/mini-graph-card1 reaction · 6 comments
- Feb 5, 2021Add haptic/vibration support from the external bus in webview — home-assistant/android1 reaction
17 more on GitHub
- Oct 26, 2026Listing check report — wolffcatskyy/awesome-home-assistant0 reactions
- Oct 19, 2026Listing check report — wolffcatskyy/awesome-home-assistant0 reactions
- Oct 17, 2026docs/tests: guard compact header wrapping and numeric sensor labels (#160) — rozkalnsandris/home-assistant-config0 reactions
- Oct 17, 2026Prevent compact header truncation and invalid numeric UI labels — rozkalnsandris/home-assistant-config0 reactions · 1 comment
- Oct 12, 2026Listing check report — wolffcatskyy/awesome-home-assistant0 reactions
- Sep 25, 2026Mājas YAML: align dashboard and audit tooling with Home Assistant 2026.9 — rozkalnsandris/home-assistant-config0 reactions · 3 comments
- Sep 18, 2026No readme — benmac7/Home-Assistant0 reactions
- Jul 18, 2026README: incorrect screenshot in Step 1, missing Card Mod install step, and missing dependency links — deanhalllincoln/AxleEventButtonCard0 reactions · 1 comment
- Apr 26, 2026Kiosk dashboard rebuild: custom:grid-layout view + typed cards (drop html-template-card) — lentago/epigaea0 reactions
- Oct 7, 2025Dialog too wide (full screen width) — home-assistant/frontend0 reactions · 2 comments
- Sep 12, 2025Add repository links and installation dates for themes and frontend resources — loryanstrant/HA-CustomComponentMonitor0 reactions
- Apr 30, 2023Add confirmation dialog box — UI-Lovelace-Minimalist/UI0 reactions · 1 comment
- Mar 5, 2022Add repeat_limit to BaseActionConfig — custom-cards/custom-card-helpers0 reactions · 1 comment
- Nov 16, 2020Deep press causes issues with double_tap_action and tap_action. — roflcoopter/deep-press0 reactions · 10 comments
- Jul 15, 2020Add handleActionConfig to allow people to run their own ActionConfig — custom-cards/custom-card-helpers0 reactions · 1 comment
- May 26, 2020Change size of actual button? — Savjee/button-text-card0 reactions · 5 comments
- Oct 12, 2019Button Card — tomhoover/home-assistant_config0 reactions
On Bluesky · 3
- May 9, 2026https://github.com/custom-cards/button-card — @tom-doerr.bsky.social1 likes and repost
- Jan 2, 2025I've also really enjoyed working with the custom button card github.com/custom-cards..., which offers a lot more customization than the… — @chrisraible.com1 likes and repost · 1 reply
- Dec 13, 2023Thanks! I used Custom Button Card for the date and weather. — @patrickklijzing.eurosky.social1 likes and repost
Where files are headingNew Copilot instructions files have more rules about branches and pull requests, and fewer about code style.
Of the Copilot instructions files we read, the 2,297 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

