Overview
TheBotonDescarga component is a styled download link button for PDF files and other downloadable resources. It features:
- Native HTML download functionality
- Hover state with color transition
- Download emoji icon (📥)
- Flex layout with icon and text
- Purple gradient styling matching the app theme
- No external dependencies (pure CSS-in-JS)
Props
URL or path to the file to be downloaded. Can be a relative path (e.g.,
/pdfs/report.pdf) or absolute URLDisplay text for the download button, describing what will be downloaded
Usage Example
FromProyectoDetalle.jsx, showing how download buttons are rendered from project data:
Expected Data Structure
TheproyectoData.pdfs array should have this structure:
Component Structure
The component is implemented as a styled anchor tag with inline event handlers:Styling Details
Default State
| Property | Value |
|---|---|
| Background Color | #836FFF (purple) |
| Text Color | #F0F3FF (off-white) |
| Padding | 12px (all sides) |
| Border Radius | 8px |
| Font Weight | bold |
| Layout | Flex with 10px gap |
Hover State
| Property | Value |
|---|---|
| Background Color | #6f5acb (darker purple) |
| Transition | 0.3s (smooth color change) |
| Cursor | pointer |
Icon and Text
- Icon: 📥 emoji at
1.2remfont size - Text:
0.9remfont size, inherits bold weight - Gap:
10pxspacing between icon and text
Download Behavior
The This works for same-origin files. For cross-origin files, the browser may navigate instead of downloading.
download attribute on the <a> tag triggers a file download instead of navigation:Specifying Download Filename
You can suggest a filename for the download:Accessibility Considerations
Multiple Buttons Layout
When rendering multiple download buttons, use a flex column layout with gap:Customization Examples
Different File Types
Change the emoji icon based on file type:Icon from Material-UI
Replace the emoji with a Material-UI icon:Gradient Background
Add a gradient instead of solid color:Event Handling Enhancement
Track download events with analytics:Browser Compatibility
The
download attribute is supported in all modern browsers:- Chrome 14+
- Firefox 20+
- Safari 10.1+
- Edge 13+
Security Considerations
- Always validate that the
archivoURL points to a safe, expected location - For user-uploaded files, implement server-side file type validation
- Consider adding virus scanning for uploaded PDFs
- Use Content-Security-Policy headers to restrict download sources
Related Components
- TarjetasContenido - Container for download buttons
- ContenidoVideo - Video embed component
- BotonFlotante - Floating back button