B4A Library [B4X][B4A] B4XDaisyCollapse - Bring Beautiful DaisyUI Expandable Views to Your Apps! 🚀

Hi Fam!

Are you looking to add modern, elegant, and highly customizable accordion or expandable sections to your app's UI? I'm excited to introduce B4XDaisyCollapse!
Based on the beautiful DaisyUI design system, this collapse component allows you to seamlessly show and hide content with professional styling and smooth state changes.

1772584968992.png
1772585065849.png


✨ Key Features:
  • DaisyUI Variants: Fully supports semantic variants like primary, secondary, accent, info, success, warning, and error.
  • Custom Icons: Built-in expansion indicators (arrow or plus) that can be positioned on the left or right to visually guide your users.
  • Highly Customizable: Easily tweak border radiuses (rounded-md, rounded-full, etc.), shadows (sm to 2xl), border widths, and title text styling.
  • Nested Content: Safely add any B4XView into the ContentView container. The component auto-measures your content's height so you don't have to guess dimensions!
  • Responsive Widths: Works natively with Tailwind-style fraction widths (e.g., w-full, w-1/2, w-1/3).
💻 Simple Usage Example: Here's a quick snippet showing how easy it is to interact with the component programmatically:

B4X:
Sub Globals
    ' Assuming myCollapse is added via the visual designer
    Private myCollapse As B4XDaisyCollapse
End Sub

Sub B4XPage_Created (Root1 As B4XView)
    Root1.LoadLayout("Main")

    ' Configure the title and style programmatically
    myCollapse.TitleText = "Click to Expand Me!"
    myCollapse.Variant = "primary"
    myCollapse.Icon = "arrow"

    ' Create and add content to the collapse container
    Dim lblContent As Label
    lblContent.Initialize("")
    lblContent.Text = "Here is the hidden content revealed!"
    lblContent.TextSize = 14
    ' Automatically adapt the text color based on the selected variant
    lblContent.TextColor = myCollapse.CollapseContent.TextColor

    ' Add the label to the inner content view.
    ' We use 0dip left because the container automatically provides standard 16dip padding.
    myCollapse.ContentView.AddView(lblContent, 0, 8dip, myCollapse.ContentView.Width, 36dip)
End Sub

' Listen for state changes (perfect for repositioning views in a ScrollView!)
Private Sub myCollapse_StateChanged (Open As Boolean)
    Log("Collapse state is now open: " & Open)
End Sub

Let me know what you think and share screenshots of how you use it in your apps! Happy coding! 🚀


Related Content

 
Last edited:

hatzisn

Expert
Licensed User
Longtime User
Great UI component. If I have understood correctly from the code Contentview is a panel where you can load a layout also?
 
Top