Przejdź do treści
Biblioteka skilli
Programowanie · Budowanie i kod

jaspr-styling

/jaspr-styling

Pisze typowo bezpieczny CSS w Dart do stylowania komponentów Jaspr, wdrażania motywów i używania właściwości CSS.

Repozytorium
blocsignal ↗
Licencja
MIT
Ostatnia zmiana repozytorium
25.10.2026

Ocena i bezpieczeństwo

100/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
8
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
0
Przestarzałość

Brak sygnałów. Repozytorium zmienione 25.10.2026, bez odwołań do wycofanych modeli i API.

Licencja

MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.

Co robi i kiedy

Pisze typowo bezpieczny CSS w Dart do stylowania komponentów Jaspr, wdrażania motywów i używania właściwości CSS.

Oryginalny opis (EN)

Write type-safe CSS-in-Dart to style Jaspr components. Use this skill when styling components, implementing themes, or using CSS properties.

Jak działa

  1. Rules for Styling
  2. Jaspr Styles Properties
Sekcje z nagłówków SKILL.md, w oryginale · 204 linii, 771 słów
Podgląd SKILL.md
---
name: jaspr-styling
description: Write type-safe CSS-in-Dart to style Jaspr components. Use this skill when styling components, implementing themes, or using CSS properties.
metadata:
  jaspr_version: 0.23.1
---

## Rules for Styling

Jaspr provides a native, type-safe **CSS-in-Dart** styling API via the `Styles` class.

### 1. Component-Level Styles (`@css` annotation)

The recommended approach for defining styles in Jaspr is inside your components to ensure better code locality.

- **Rule 1:** You MUST use the `@css` annotation on a static getter returning `List<StyleRule>` to scope styles to a component.
- **Rule 2:** You MUST use specific CSS selectors (like `.main` classes or `#id` ids) within `css()` to prevent your styles from bleeding into other components, as `@css` styles are globalized during rendering.

```dart
class App extends StatelessComponent {
  const App({super.key});

  @override
  Component build(BuildContext context) {
    return div(classes: 'main', [
      p([.text('Hello World')]),
    ]);
  }

  @css
  static List<StyleRule> get styles => [
    css('.main', [
      // Use css('&') to refer to the parent selector (.main)
      css('&').styles(
        width: 100.px, // Note: Use `.px`, `.rem`, `.percent` extensions on numbers.
        padding: .all(10.rem),
        display: .flex,
      ),
      css('&:hover').styles(
        backgroundColor: Colors.blue,
      ),
      css('p').styles(
        color: Colors.blue,
      ),
    ]),
    // Responsive queries
    css.media(MediaQuery.screen(maxWidth: 600.px), [
      css('.main').styles(flexDirection: .column),
    ])
  ];
}
```

### 2. Inline Styles

You can pass `Styles` instances directly to native HTML components. This renders as the `style="..."` HTML attribute.

- **Rule 1:** You MUST ONLY use inline styles for **dynamic styles** (e.g., styles that change based on state or parameters).
- **Rule 2:** For static styles, you MUST use the component-level `@css` annotation.
- **Rule 3:** You MUST NOT use inline styles for complex rules like media queries, hover states, or animations.

```dart
// Example of dynamic inline styling driven by state
class ColorBox extends StatelessComponent {
  final Color boxColor;

  const ColorBox({required this.boxColor, super.key});

  @override
  Component build(BuildContext context) {
    return div(styles: Styles(backgroundColor: boxColor), []);
  }
}
```

### 3. Global `@css` Styles

You can define a global set of styles directly from Dart using the `@css` annotation on a global variable or getter.

- **Rule 1:** Just like component-level `@css`, global `@css` is ONLY supported in **server** and **static** modes.
- **Rule 2:** You MUST place global `@css` annotations on top-level getters or static getters returning `List<StyleRule>`.

```dart
@css
List<StyleRule> get globalStyles => [
  css('body').styles(
    margin: .zero,
    fontFamily: .list([FontFamily('Roboto'), FontFamilies.sansSerif]),
    backgroundColor: Colors.white,
  ),
  css('a').styles(
    textDecoration: TextDecoration(line: .none),
    color: Colors.blue,
  ),
];
```

### 4. Global External Stylesheets

- **Rule:** If you are using raw `.css` files (or other css frameworks like sass/scss, tailwind, etc.), you MUST include them using a `<link rel="stylesheet">` element inside the `Document(head: [...])` component (for server/static mode) or in `web/index.html` (for client mode).

---

## Jaspr Styles Properties

To avoid guessing CSS properties and overwhelming context, Jaspr maps CSS properties to strongly-typed Dart classes.

Here is the full list of properties both the `Styles()` class and `.styles()` method support:

```dart
Styles({ // or .styles({
  All? all,
  // Box Styles
  String? content,
  Display? display,
  Position? position,
  ZIndex? zIndex,
  Unit? width,
  Unit? height,
  Unit? minWidth,
  Unit? minHeight,
  Unit? maxWidth,
  Unit? maxHeight,
  AspectRatio? aspectRatio,
  Padding? padding,
  Margin? margin,
  BoxSizing? boxSizing,
  Border? border,
  BorderRadius? radius,
  Outline? outline,
  double? opacity,
  Visibility? visibility,
  Overflow? overflow,
  Appearance? appearance,
  BoxShadow? shadow,
  Filter? filter,
  Filter? backdropFilter,
  Cursor? cursor,
  UserSelect? userSelect,
  PointerEvents? pointerEvents,
  Animation? animation,
  Transition? transition,
  Transform? transform,
  // Flexbox Styles
  FlexDirection? flexDirection,
  FlexWrap? flexWrap,
  JustifyContent? justifyContent,
  AlignItems? alignItems,
  AlignContent? alignContent,
  // Grid Styles
  GridTemplate? gridTemplate,
  List<TrackSize>? autoRows,
  List<TrackSize>? autoColumns,
  JustifyItems? justifyItems,
  Gap? gap,
  // Item Styles
  Flex? flex,
  int? order,
  AlignSelf? alignSelf,
  JustifySelf? justifySelf,
  GridPlacement? gridPlacement,
  // List Styles
  ListStyle? listStyle,
  ImageStyle? listImage,
  ListStylePosition? listPosition,
  // Text Styles
  Color? color,
  TextAlign? textAlign,
  FontFamily? fontFamily,
  Unit? fontSize,
  FontWeight? fontWeight,
  FontStyle? fontStyle,
  TextDecoration? textDecoration,
  TextTransform? textTransform,
  Unit? textIndent,
  Unit? letterSpacing,
  Unit? wordSpacing,
  Unit? lineHeight,
  TextShadow? textShadow,
  TextOverflow? textOverflow,
  WhiteSpace? whiteSpace,
  Quotes? quotes,
  // Background Styles
  Color? backgroundColor,
  ImageStyle? backgroundImage,
  BackgroundOrigin? backgroundOrigin,
  BackgroundPosition? backgroundPosition,
  BackgroundAttachment? backgroundAttachment,
  BackgroundRepeat? backgroundRepeat,
  BackgroundSize? backgroundSize,
  BackgroundClip? backgroundClip,
  // Raw Styles
  Map<String, String>? raw,
})
```

- **Rule 1:** You MUST define all properties in the order they are defined in the `Styles` class.
- **Rule 2:** You MUST use dot-shorthands for all style properties and values where applicable (e.g., `padding: .all(10.px)` instead of `padding: Padding.all(Unit.pixels(10))`, or `justifyContent: .center` instead of `justifyContent: JustifyContent.center`).
- **Rule 3:** You MUST use `raw` for any properties that are not supported by the `Styles` class.

**IMPORTANT:** Before writing styles in one of the below areas, you **MUST** read the respective reference file provided alongside this skill:

- `references/sizing.md` (Units like `.px`, `.percent`, dimensions, margin, padding, borders, border-radius)
- `references/color.md` (Colors, HEX, RGB, HSL values)
- `references/box.md` (Position, overflow, transform, background, cursor, filters, z-index, visibility)
- `references/typography.md` (Text alignment, fonts, text decoration, letter spacing)
- `references/flexbox.md` (Flexbox container/item, flex layout, alignments)
- `references/grid.md` (Grid layout, track sizes, gaps, templates)
- `references/animation.md` (Transitions, Animations, keyframes, curves, durations)
Pliki w paczce (8)
  • SKILL.md 7 KB
  • references/animation.md 2 KB
  • references/box.md 2 KB
  • references/color.md 1 KB
  • references/flexbox.md 1 KB
  • references/grid.md 3 KB
  • references/sizing.md 2 KB
  • references/typography.md 1 KB

Wersje

W bazie nie ma innych skilli o nazwie jaspr-styling.

Migawka bazy z 13.11.2026 · wersja paczki 1070ac85df2e (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 0 · ranking

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 100jaspr-fundamentals
    Opisuje podstawy pracy w projekcie Jaspr: pisanie komponentów Jaspr i korzystanie z komponentów HTML.
  • 100jaspr-convert-html
    Przepisuje istniejący kod HTML (z pliku lub adresu URL) na kod Jaspr.
  • 100tailwind-patterns
    Dobiera wzorce Tailwind CSS v4 do stylowania komponentów, trybu ciemnego i integracji z systemem projektowym.
  • 100styling-with-tailwind
    Dostarcza wzorce stylowania utility-first z Tailwind CSS 3.x: klasy narzędziowe, tailwind.config.js, responsywne układy i motywy ciemne.
  • 100gpui-layout-and-style
    Obsługuje układ i stylowanie komponentów w GPUI, w tym systemy layoutu i właściwości podobne do CSS.
  • 100material-ui-styling
    Dobiera właściwe podejście do stylowania w Material UI (sx, styled, nadpisania motywu, globalny CSS) według oficjalnych zaleceń MUI przy dostosowywaniu komponentów i motywów.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.