Tables are designed to show data in a tabular layout making it easy to see large amounts of data at once and compare rows with each other.

Basic Table

Here is a super-basic table.

Column 1 Column 2
foo bar
fizz buzz
- data = [{col1: "foo", col2: "bar"}, {col1: "fizz", col2: "buzz"}]

= daisy_table do |table|
  - table.with_head do |head|
    - head.with_column do
      Column 1
    - head.with_column do
      Column 2

  - data.each do |d|
    - table.with_row do |row|
      - row.with_column do
        = d[:col1]
      - row.with_column do
        = d[:col2]

Pass sticky: to the head and its <tr> pins to the top of the scroll container, wired to LocoMotion's loco-sticky controller, which stamps data-stuck on the row while it is actually pinned. The offset goes in row_css: (it is never emitted for you, so it can't fight your own utilities), and stuck: utilities — on the row or on its cells — style the pinned state. Scroll the box to see the header pick up a shadow and its titles change color.

Name Role
Person 1 Developer
Person 2 Designer
Person 3 Manager
Person 4 Analyst
Person 5 Developer
Person 6 Designer
Person 7 Manager
Person 8 Analyst
Person 9 Developer
Person 10 Designer
Person 11 Manager
Person 12 Analyst
Person 13 Developer
Person 14 Designer
Person 15 Manager
Person 16 Analyst
Person 17 Developer
Person 18 Designer
Person 19 Manager
Person 20 Analyst
Person 21 Developer
Person 22 Designer
Person 23 Manager
Person 24 Analyst
Person 25 Developer
Person 26 Designer
Person 27 Manager
Person 28 Analyst
Person 29 Developer
Person 30 Designer
.h-80.w-full.max-w-lg.border.border-base-300.rounded.overflow-y-auto
  = daisy_table(css: "bg-base-100") do |table|
    - table.with_head(sticky: "top", row_css: "top-0 bg-base-100 stuck:shadow-md transition-shadow") do |head|
      - head.with_column(css: "stuck:text-primary transition-colors") do
        Name
      - head.with_column(css: "stuck:text-primary transition-colors") do
        Role

    - 30.times do |i|
      - table.with_row do |row|
        - row.with_column do
          = "Person #{i + 1}"
        - row.with_column do
          = %w[Developer Designer Manager Analyst][i % 4]

Pinned First Column

Cells are the elements that stick in a table, so a pinned column is sticky: "left" on each of its cells (header and body). Each pinned cell reports its own data-stuck, so stuck-left: utilities on the cell draw the divider only while the column is actually pinned. Scroll the box sideways.

Name Q1 Q2 Q3 Q4 Q5 Q6 Q7 Q8
Alice 7 14 21 28 35 42 49 56
Bob 14 28 42 56 70 84 98 112
Carol 21 42 63 84 105 126 147 168
Dave 28 56 84 112 140 168 196 224
.w-full.max-w-lg.border.border-base-300.rounded.overflow-x-auto
  = daisy_table(css: "bg-base-100 w-max") do |table|
    - table.with_head do |head|
      - head.with_column(sticky: "left", css: "left-0 bg-base-100 stuck-left:border-r stuck-left:border-base-300") do
        Name
      - %w[Q1 Q2 Q3 Q4 Q5 Q6 Q7 Q8].each do |quarter|
        - head.with_column(css: "min-w-32") do
          = quarter

    - %w[Alice Bob Carol Dave].each_with_index do |name, r|
      - table.with_row do |row|
        - row.with_column(sticky: "left", css: "left-0 bg-base-100 stuck-left:border-r stuck-left:border-base-300") do
          = name
        - 8.times do |q|
          - row.with_column do
            = (r + 1) * (q + 1) * 7

Pinning Rows (Using Sections)

The following example shows how to have a table with multiple headers pinned as you scroll.

1900s
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910s
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920s
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930s
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940s
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950s
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960s
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970s
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980s
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990s
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
.h-96.w-full.max-w-96.border.border-base-300.rounded.overflow-y-auto
  = daisy_table(css: "bg-base-100 table-pin-rows") do |table|
    - (0..90).step(10).with_index do |step, index|
      - table.with_section do |section|
        - section.with_head do |head|
          - head.with_column(css: 'bg-secondary text-secondary-content') do
            - if step == 0
              1900s
            - else
              = "19#{index * 10}s"

        - section.with_body do |body|
          - (0..9).each do |i|
            - body.with_row do |row|
              - row.with_column do
                - if step == 0
                  = "190#{step + i}"
                - else
                  = "19#{step + i}"
Made with by Profoundry .
Copyright © 2023-2026 Profoundry LLC.
All rights reserved.