@@ -61,7 +61,7 @@ pip install streamlit-scroll-navigation
61
61
import streamlit as st
62
62
from streamlit_scroll_navigation import scroll_navbar
63
63
64
- # Specify anchor IDs and icons
64
+ # Anchor IDs and icons
65
65
anchor_ids = [" About" , " Features" , " Settings" , " Pricing" , " Contact" ]
66
66
anchor_icons = [" info-circle" , " lightbulb" , " gear" , " tag" , " envelope" ]
67
67
@@ -70,8 +70,7 @@ with st.sidebar:
70
70
st.subheader(" Example 1" )
71
71
scroll_navbar(
72
72
anchor_ids,
73
- # key="navbar1", #use for first navbar
74
-
73
+ anchor_labels = None , # Use anchor_ids as labels
75
74
anchor_icons = anchor_icons)
76
75
77
76
# 2. horizontal menu
@@ -82,56 +81,7 @@ scroll_navbar(
82
81
anchor_icons = anchor_icons,
83
82
orientation = " horizontal" )
84
83
85
- # 3. Custom anchor labels with no icons
86
- st.subheader(" Example 3" )
87
- scroll_navbar(
88
- anchor_ids,
89
- key = " navbar3" ,
90
- anchor_labels = [" About Us" , " The Features" , " The Settings" , " The Pricing" , " Contact Us" ],
91
- orientation = " horizontal" )
92
-
93
- # 4. Style overrides
94
- st.subheader(" Example 4" )
95
- scroll_navbar(
96
- anchor_ids = anchor_ids,
97
- key = " navbar4" ,
98
- orientation = " horizontal" ,
99
- override_styles = {
100
- " navbarButtonBase" : {
101
- " backgroundColor" : " #007bff" , # Set a custom button background color
102
- " color" : " #ffffff" , # Set custom text color
103
- },
104
- " navbarButtonHover" : {
105
- " backgroundColor" : " #0056b3" , # Set a custom hover color for the buttons
106
- },
107
- " navigationBarBase" : {
108
- " backgroundColor" : " #f8f9fa" , # Change the navigation bar background color
109
- }
110
- }
111
- )
112
-
113
- # 5. Force anchor
114
- st.subheader(" Example 5" )
115
- force_body = None
116
- if st.button(" Go to Body" ):
117
- force_body = " Body"
118
- scroll_navbar(
119
- anchor_ids,
120
- key = " 5" ,
121
- anchor_icons = anchor_icons,
122
- orientation = " horizontal" ,
123
- force_anchor = force_body)
124
-
125
- # 6. Retrieve active anchor
126
- with st.sidebar:
127
- st.subheader(" Example 6" )
128
- active_anchor = scroll_navbar(
129
- anchor_ids,
130
- key = " navbar6" ,
131
- orientation = " vertical" )
132
- st.write(f " { active_anchor} is active " )
133
-
134
- # Setup dummy page
84
+ # Dummy page setup
135
85
for anchor_id in anchor_ids:
136
86
st.subheader(anchor_id,anchor = anchor_id)
137
87
st.write(" content " * 100 )
0 commit comments