CtrlK
BlogDocsLog inGet started
Tessl Logo
PluginPublic

adobe/aem-forms-edge-delivery-services

Skills for AEM Forms on Edge Delivery Services: building forms with the Form block.

Quality

96%

Does it follow best practices?

Run evals on this skill

Adds up to 20 points to the overall score

View guide
SecuritybySnyk

Passed

No findings from the security scan

Overview
Quality
Evals
Security
Files

styling.mdskills/create-custom-component/references/

CSS Styling Patterns for Form Components

Source: Customize the look of your forms — CSS Styling Patterns and Best Practices (Experience League).

The Adaptive Forms Block follows specific CSS patterns that keep styling maintainable, performant, and consistent across components. Follow them when writing <name>.css for a custom component.


Primary styling patterns

In a custom component's stylesheet, start every selector with .form and a class that decorate() adds. The .{type}-wrapper classes below come from the field's base fieldType (a number-input field renders as .number-wrapper), not from the component name. A .<name>-wrapper selector matches nothing unless decorate() adds that class. See Applying this to a custom component's stylesheet.

Field-type wrapper classes. The form block puts each field in a wrapper whose class is derived from its base field type. Use these for form-wide theming, not in a component stylesheet:

/* Text input fields */
.form .text-wrapper input {
    padding: var(--form-input-padding);
    border: var(--form-input-border-size) solid var(--form-input-border-color);
    font-size: var(--form-input-font-size);
    border-radius: 4px;
    width: 100%;
}

/* Email input fields */
.form .email-wrapper input {
    padding: var(--form-input-padding);
    border: var(--form-input-border-size) solid var(--form-input-border-color);
    font-size: var(--form-input-font-size);
}

/* Button styling */
.form .button-wrapper button {
    background-color: var(--form-button-background-color);
    color: var(--form-button-color);
    padding: var(--form-button-padding);
    border: var(--form-button-border);
    font-size: var(--form-button-font-size);
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.form .button-wrapper button:hover {
    background-color: var(--form-button-background-hover-color);
}

Advanced customization patterns

Field-specific targeting. Target an individual field by name for unique styling needs:

/* Style specific fields */
.form .field-email input {
    background-image: url('data:image/svg+xml;...'); /* Email icon */
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 40px;
}

.form .field-phone input {
    text-align: center;
    letter-spacing: 1px;
    font-family: monospace;
}

State-based styling. Implement validation and interaction states:

The form block adds .field-invalid to the field wrapper when showing an error and removes it when clearing the error. Use this class rather than data-valid attributes. Its absence does not distinguish an untouched field from a validated field, so the example does not add a success style.

/* Validation error state */
.form .field-invalid input {
    border-color: var(--form-error-color);
    box-shadow: 0 0 0 2px rgba(255, 95, 63, 0.1);
}

/* Focus states */
.form .text-wrapper input:focus,
.form .email-wrapper input:focus {
    outline: none;
    border-color: var(--button-primary-color);
    box-shadow: 0 0 0 2px rgba(95, 141, 218, 0.2);
}

Applying this to a custom component's stylesheet

The .{Type}-wrapper class comes from the field's base fieldType, not from the component name. A loan-slider built on number-input renders as <div class="number-wrapper field-wrapper field-<name>" data-id="…">: the form block never adds a .loan-slider-wrapper class, so a selector such as .form .loan-slider-wrapper .loan-slider-range matches nothing and none of its rules apply.

  • Start every selector with .form and a class that decorate() adds, prefixed with the component name: for example, .form .loan-slider-widget for the container element that decorate() creates.
  • To style the field wrapper itself, add the class in decorate() (fieldDiv.classList.add('<name>')) and target that. Don't style .{base type}-wrapper in a component stylesheet: it also matches every other field of the same base type.
  • Use field-name targeting (.form .field-{name}) only for one-off, form-specific styling, never in a reusable component's stylesheet.
  • Style validation and interaction states with the state patterns above (validation, :focus).

README.md

tile.json