> Markdown version of [Styling](https://vaadin.com/docs/next/components/password-field/styling). Section index: [llms.txt](https://vaadin.com/docs/next/components/llms.txt)

# Password Field Styling

## <a id="style-variants"></a>Style Variants

The following style variants can be applied:

| Variant              | Description                                                                                                                  | Supported by |
| -------------------- | ---------------------------------------------------------------------------------------------------------------------------- | ------------ |
| `align-left`         | Aligns the text to the left side of the field (default)                                                                      | Aura, Lumo   |
| `align-center`       | Centers the text within the field                                                                                            | Aura, Lumo   |
| `align-right`        | Aligns the text to the right side of the field. Recommended for numerical values when presented in vertical groups.          | Aura, Lumo   |
| `align-start`        | Aligns the text to the start side of the field, taking into account the current text direction (left for LTR, right for RTL) | Aura         |
| `align-end`          | Aligns the text to the end side of the field, taking into account the current text direction (right for LTR, left for RTL)   | Aura         |
| `small`              | Renders a more compact field                                                                                                 | Aura, Lumo   |
| `helper-above-field` | Renders the helper above the field, and below the label                                                                      | Aura, Lumo   |

**Lit** — `password-field-styles.ts`

```typescript
<vaadin-password-field
  theme="align-right small helper-above-field"
  label="Label"
  helper-text="Helper text"
  value="Ex@mplePassw0rd"
></vaadin-password-field>
```

**Flow** — `PasswordFieldStyles.java`

```java
PasswordField field = new PasswordField();
field.addThemeVariants(TextFieldVariant.SMALL,
        TextFieldVariant.ALIGN_RIGHT, TextFieldVariant.HELPER_ABOVE);
```

**React** — `password-field-styles.tsx`

```tsx
<PasswordField
  theme="align-right small helper-above-field"
  label="Label"
  helperText="Helper text"
  value="Ex@mplePassw0rd"
/>
```

## <a id="style-properties"></a>Style Properties

The following style properties can be used in CSS stylesheets to customize the appearance of this component.

To apply values to these properties globally in your application UI, place them in a CSS block using the `html {…​}` selector. See [Component Style Properties](https://vaadin.com/docs/next/styling/styling-components.md#component-style-properties) for more information on style properties.

> **Note: Input Field Components Shared Styles**
>
> Style properties whose names start with `--vaadin-input-field` are shared among all input field components. To apply them only to a specific type of component, use an element selector like `vaadin-text-field {…​}`

### <a id="field-surface"></a>Field Surface

#### <a id="common-properties"></a>Common Properties

| Property                                   | Supported by |
| ------------------------------------------ | ------------ |
| `--vaadin-field-default-width`             | Aura, Lumo   |
| `--vaadin-input-field-background`          | Aura, Lumo   |
| `--vaadin-input-field-border-color`        | Aura, Lumo   |
| `--vaadin-input-field-border-radius`       | Aura, Lumo   |
| `--vaadin-input-field-border-width`        | Aura, Lumo   |
| `--vaadin-input-field-bottom-end-radius`   | Aura, Lumo   |
| `--vaadin-input-field-bottom-start-radius` | Aura, Lumo   |
| `--vaadin-input-field-container-gap`       | Aura         |
| `--vaadin-input-field-gap`                 | Aura         |
| `--vaadin-input-field-height`              | Lumo         |
| `--vaadin-input-field-padding`             | Aura         |
| `--vaadin-input-field-placeholder-color`   | Aura, Lumo   |
| `--vaadin-input-field-top-start-radius`    | Aura, Lumo   |
| `--vaadin-input-field-top-end-radius`      | Aura, Lumo   |
| `--vaadin-input-field-value-color`         | Aura, Lumo   |
| `--vaadin-input-field-value-font-size`     | Aura, Lumo   |
| `--vaadin-input-field-value-font-weight`   | Aura, Lumo   |
| `--vaadin-input-field-value-line-height`   | Aura, Lumo   |

#### <a id="field-states"></a>Field States

| Property                                       | Supported by |
| ---------------------------------------------- | ------------ |
| `--vaadin-focus-ring-width`                    | Aura, Lumo   |
| `--vaadin-focus-ring-color`                    | Aura, Lumo   |
| `--vaadin-input-field-disabled-background`     | Aura, Lumo   |
| `--vaadin-input-field-disabled-text-color`     | Aura         |
| `--vaadin-input-field-disabled-value-color`    | Lumo         |
| `--vaadin-input-field-hover-highlight`         | Lumo         |
| `--vaadin-input-field-hover-highlight-opacity` | Lumo         |
| `--vaadin-input-field-invalid-background`      | Lumo         |
| `--vaadin-input-field-invalid-hover-highlight` | Lumo         |
| `--vaadin-input-field-readonly-border`         | Lumo         |

### <a id="label"></a>Label

| Property                                        | Supported by |
| ----------------------------------------------- | ------------ |
| `--vaadin-input-field-focused-label-color`      | Lumo         |
| `--vaadin-input-field-hovered-label-color`      | Lumo         |
| `--vaadin-input-field-label-color`              | Aura, Lumo   |
| `--vaadin-input-field-label-font-size`          | Aura, Lumo   |
| `--vaadin-input-field-label-font-weight`        | Aura, Lumo   |
| `--vaadin-input-field-label-line-height`        | Aura, Lumo   |
| `--vaadin-input-field-required-indicator-color` | Aura, Lumo   |
| `--vaadin-input-field-required-indicator`       | Aura, Lumo   |

### <a id="helper"></a>Helper

| Property                                  | Supported by |
| ----------------------------------------- | ------------ |
| `--vaadin-input-field-helper-color`       | Aura, Lumo   |
| `--vaadin-input-field-helper-font-size`   | Aura, Lumo   |
| `--vaadin-input-field-helper-font-weight` | Aura, Lumo   |
| `--vaadin-input-field-helper-line-height` | Aura, Lumo   |
| `--vaadin-input-field-helper-spacing`     | Lumo         |

### <a id="error-message"></a>Error Message

| Property                                 | Supported by |
| ---------------------------------------- | ------------ |
| `--vaadin-input-field-error-color`       | Aura, Lumo   |
| `--vaadin-input-field-error-font-size`   | Aura, Lumo   |
| `--vaadin-input-field-error-font-weight` | Aura, Lumo   |
| `--vaadin-input-field-error-line-height` | Aura, Lumo   |

### <a id="field-buttons"></a>Field Buttons

| Property                                 | Supported by |
| ---------------------------------------- | ------------ |
| `--vaadin-clickable-cursor`              | Aura         |
| `--vaadin-disabled-cursor`               | Aura         |
| `--vaadin-icon-size`                     | Aura         |
| `--vaadin-icon-visual-size`              | Aura         |
| `--vaadin-input-field-button-text-color` | Aura         |
| `--vaadin-input-field-icon-size`         | Lumo         |
| `--vaadin-input-field-icon-color`        | Lumo         |

## <a id="css-selectors"></a>CSS Selectors

The following CSS selectors can be used in stylesheets to target the various parts and states of the component. See the [Styling documentation](https://vaadin.com/docs/next/styling.md) for more details on how to style components.

> **Important: Not for Shadow DOM**
>
> These selectors should be used in `styles.css` or another stylesheet loaded with the `@StyleSheet` annotation or the `@import` CSS rule. **They do not work in the shadow DOM of Vaadin components**, such as in stylesheets in the `components` sub-folder or loaded with the `@CssImport` annotation’s `themeFor` property.

---

- Root element

  `vaadin-password-field`

### <a id="states"></a>States

- Required

  `vaadin-password-field[required]`

- Focused

  `vaadin-password-field[focused]`

- Keyboard focused

  `vaadin-password-field[focus-ring]`

- Read-only

  `vaadin-password-field[readonly]`

- Disabled

  `vaadin-password-field[disabled]`

- Not empty

  `vaadin-password-field[has-value]`

- With tooltip

  `vaadin-password-field[has-tooltip]`

- Hovered

  `vaadin-password-field:hover`

- Password visible

  `vaadin-password-field[password-visible]`

- Password masked

  `vaadin-password-field:not([password-visible])`

### <a id="field"></a>Field

- Field surface (background, border)

  `vaadin-password-field::part(input-field)`

- Native input element

  `vaadin-password-field > input`

- Input field with placeholder shown

  `vaadin-password-field > input:placeholder-shown`

- Clear and Reveal buttons

  `vaadin-password-field::part(field-button)`

- Clear button

  `vaadin-password-field::part(clear-button)`

- Clear button icon

  `vaadin-password-field::part(clear-button)::before`

- Prefix element

  `vaadin-password-field > [slot="prefix"]`

- Suffix element

  `vaadin-password-field > [slot="suffix"]`

- Reveal button

  `vaadin-password-field::part(reveal-button)`

- Reveal button icon

  `vaadin-password-field::part(reveal-button)::before`

### <a id="label-2"></a>Label

- Field with label

  `vaadin-password-field[has-label]`

- Label

  `vaadin-password-field::part(label)`

- Label text

  `vaadin-password-field > label`

- Required indicator

  `vaadin-password-field::part(required-indicator)`

### <a id="helper-and-validation-error"></a>Helper and Validation Error

- Field with helper

  `vaadin-password-field[has-helper]`

- Helper

  `vaadin-password-field::part(helper-text)`

- Helper text

  `vaadin-password-field > [slot="helper"]`

- Invalid field

  `vaadin-password-field[invalid]`

- Field with error message

  `vaadin-password-field[has-error-message]`

- Error message

  `vaadin-password-field::part(error-message)`

- Error message text

  `vaadin-password-field > [slot="error-message"]`
