Button
El prop `callbackEvent` hace que el botón emita un evento DOM con ese nombre al pulsarlo. Es la forma de darle comportamiento a un botón Astro nativo, sin island de React.
import Button from '#LibComponents/astronative/atomic/Button/Button.astro';<AC.Button id="btn" callbackEvent="btnClicked" label="Pulsar" />
<script>
document.getElementById('contenedor')
?.addEventListener('btnClicked', () => { /* ... */ });
</script>Props del tipo del componente
| Prop | Tipo | Obligatorio | Default | Descripción |
|---|---|---|---|---|
class | string | no | — | |
callbackEvent | string | no | — | |
href | string | no | — | |
icon | string | no | — | |
iconPosition | 'left' | 'right' | no | — | |
isFilled | boolean | no | — | |
label | string | no | — | |
actionType | 'primary' | 'primary-reverse' | 'secondary' | 'light' | 'info' | 'danger' | 'none' | no | — | |
type | 'submit' | 'reset' | 'button' | no | — | |
size | 'sm' | 'md' | 'lg' | '2xl' | no | — | |
round | 'none' | 'sm' | 'lg' | 'xl' | '2xl' | 'full' | 'square' | no | — |
Ojo
- El evento burbujea: el listener del ejemplo está en el contenedor, no en el propio botón.
- Pulsar el botón de la vista previa abre un `window.alert` — es del ejemplo, no del componente.